Re: CP trigger
Posted: Sat 2. Aug 2008, 08:51
Oh hey,
check my source - there is a sample. Then you know what to do.
It is a very simple way to implement custom functions which are pocessed each time a content part is parsed in phpwcms.
You have asked in feature request yesterday for special replacement tags on content part basis. This is it but a much more common solution.
If you have a look to this:
http://code.google.com/p/phpwcms/source ... .php?r=245
Just take that and move the file one directory up - put it in here template/inc_script/frontend_init/.
Then just put in the replacement tag in your content part: {CPDATE} and check the preview link.
Custom functions have to be defined this way:
And must be registered in phpwcms - just tell the system to parse it:
You can also limit your function to work for special content parts:
Oliver
check my source - there is a sample. Then you know what to do.
It is a very simple way to implement custom functions which are pocessed each time a content part is parsed in phpwcms.
You have asked in feature request yesterday for special replacement tags on content part basis. This is it but a much more common solution.
If you have a look to this:
http://code.google.com/p/phpwcms/source ... .php?r=245
Just take that and move the file one directory up - put it in here template/inc_script/frontend_init/.
Then just put in the replacement tag in your content part: {CPDATE} and check the preview link.
Custom functions have to be defined this way:
Code: Select all
function cp_trigger_function_name($param1, & $param2) {
$param1 = do_this_or_that($param2['acontent_id']);
return $param1;
}
- cp_trigger_function_name - the unique function name
- $param1 - holds the content part html source on which you can parse or do custom processing
- $param2 - is a reference to an array which holds content part values like ID, dates and other values - see db table phpwcms_articlecontent
And must be registered in phpwcms - just tell the system to parse it:
Code: Select all
register_cp_trigger('cp_trigger_function_name', 'LAST');
Code: Select all
function cp_trigger_function_name($param1, & $param2) {
if($param2['acontent_type'] == 14) { // 14 is CP WYSIWYG
$param1 = do_this_or_that($param2['acontent_id']);
}
return $param1;
}