Page 1 of 1

Re: CP trigger

Posted: Sat 2. Aug 2008, 08:51
by Oliver Georgi
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:

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
Always return $param1;

And must be registered in phpwcms - just tell the system to parse it:

Code: Select all

register_cp_trigger('cp_trigger_function_name', 'LAST');
You can also limit your function to work for special content parts:

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;
}
Oliver

Re: CP trigger

Posted: Sat 2. Aug 2008, 08:58
by update
HEY - the beginning of a docu for tricky tricks - thanks!

Re: CP trigger

Posted: Sat 2. Aug 2008, 12:14
by flip-flop
Short description of the TABLE phpwcms_articlecontent

Code: Select all

acontent_id              Running CP counter          (int(11))
acontent_aid             Article ID                  (int(11))
acontent_uid             User ID                     (int(11))
acontent_created         Date: CP created            (timestamp)
acontent_tstamp          Date: CP updated            (timestamp)
acontent_title           Title text                  (text)
acontent_text            Text if clear text          (text)
acontent_type            content type:               (int(10))
acontent_sorting         sort value: [value]         (int(11))
acontent_image           Image text                  (text)
acontent_files           ??                          (text)
acontent_visible         Visible [0/1]               (int(1))
acontent_subtitle        Subtitle text               (text)
acontent_before          Space: before [value]       (varchar(10))
acontent_after           Space: after [value]        (varchar(10))
acontent_top             Top anchor jump [0/1]       (int(1))
acontent_redirect        ??                          (text)
acontent_html            HTML text if HTML           (text)
acontent_trash           0= available  9= trash      (int(1))
acontent_alink           ??                          (text)
acontent_media           ??                          (text)
acontent_form            Image form                  (mediumtext)
acontent_newsletter      ??                          (mediumtext)
acontent_block           display: e.g. [Content]     (varchar(200))
acontent_anchor          anchor: [0/1]               (int(1))
acontent_template        template filename if there  (varchar(255))
acontent_spacer          ??                          (int(1))
acontent_tid             ??                          (int(11))
acontent_livedate        Livedate (not in use ??)    (datetime)
acontent_killdate        Killdate (not in use ??)    (datetime)
acontent_module          Module name                 (varchar(255))
acontent_comment         notes: [value]              (text)
acontent_paginate_page   Paginate subsection: [value](int(5))
acontent_paginate_title  subsection title: [value]   (varchar(255))
acontent_category        ??                          (varchar(255)
acontent_granted         ??                          (int(11))

Re: CP trigger

Posted: Sat 2. Aug 2008, 13:25
by Oliver Georgi
Some more of the fields are very specific and - yes sorry - not clear by name. It's historical and cannot be changed easy again :(

Code: Select all

acontent_id              auto increment unique ID
acontent_aid             ID of parent article
acontent_uid             ID of the user has saved CP at last
acontent_created         Date: CP created, MySQL date format
acontent_tstamp          Date: CP updated, MySQL date format
acontent_title           Title text
acontent_text            Plain Text (in general)
acontent_type            Type of the Cntent Part - look at include/inc_lib/article.contenttype.inc.php
acontent_sorting         sort value: [value]
acontent_image           Holds image information (older CP)
acontent_files           Hold file information (older CP)
acontent_visible         Visible [0/1]
acontent_subtitle        Subtitle text
acontent_before          Space: before [value]
acontent_after           Space: after [value]
acontent_top             Top anchor jump [0/1]
acontent_redirect        can hold an URL (cannot remember at the moment)
acontent_html            also Text, can be HTML styled text but also other texts
acontent_trash           0= available  9= trash
acontent_alink           Also older CP - article link
acontent_media           CP Multimedia information
acontent_form            more complex - current CPs store serialized infos there
acontent_newsletter      ??                          (mediumtext)
acontent_block           display: e.g. [Content] - in general empty mean main block
acontent_anchor          anchor: [0/1]
acontent_template        template filename if there
acontent_spacer          ??                          (int(1))
acontent_tid             ??                          (int(11))
acontent_livedate        Livedate (not in use ??)
acontent_killdate        Killdate (not in use ??)
acontent_module          Module name
acontent_comment         notes: [value]
acontent_paginate_page   Paginate subsection: [value]
acontent_paginate_title  subsection title: [value]
acontent_category        ??
acontent_granted         if set [0/1] visible for logged-in users only
Some enhancements only ;-) - use

Code: Select all

dumpVar($varname);
to get more information based on real data.

Oliver