Event manger with modules

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
andrewvideouk
Forum Members
Forum Members
Posts: 155
Joined: Thu Aug 20, 2020 10:49 pm

Event manger with modules

Post by andrewvideouk »

Hi guys

I am trying to find infornation on Event manger and can't really find much out there.
I want to do some cleaning up some text before it saved to the database.

Only thing I found that works with Content Pages (ContentEditPre).

(UDT)

Code: Select all

$content_obj =& $params['content'];
$text = $content_obj->GetPropertyValue('content_en');
  
	$newcontent =  do_stuff_etc($text);	
	
$content_obj->SetPropertyValue('content_en',$newcontent);

I want to know what i need to change in the code to make this work with those modules.

Calandar = EventEditedPre
Lise = PreItemSave
News = NewsArticleAdded / NewsArticleEdited

Thank you
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3483
Joined: Mon Nov 28, 2011 9:29 am
Location: The Netherlands

Re: Event manger with modules

Post by velden »

Debug by printing or var_dumping the $params variable and then die()

UDT: e.g. (not tested);

Code: Select all

var_dump($params);
die();
Then connect the UDT to the event and trigger the event. Look at the results.

For LISE I use this:

Code: Select all

//use for pre-save item event

// store the company id (key) to the dividend key2
// might be useful later for efficiently selecting items
$item = $params['item_object'];
// now you can do what you want to do with $item which is a LISE Item object
andrewvideouk
Forum Members
Forum Members
Posts: 155
Joined: Thu Aug 20, 2020 10:49 pm

Re: Event manger with modules

Post by andrewvideouk »

Code below worked to get array values but I dont have a cute to replace the arrry string.

I tried something like
$params['summary'] = "new value"; (news module)

and the text don't get changed.

Thank you



This from News module

Code: Select all

array(13) { ["news_id"]=> int(22) ["category_id"]=> string(1) "1" ["title"]=> string(5) "title text" ["content"]=> string(16) "
text suff
" ["summary"]=> string(19) "
and more text
" ["status"]=> string(9) "published" ["start_time"]=> int(1642714007) ["end_time"]=> int(1658262407) ["postdate"]=> int(1642714007) ["useexp"]=> int(0) ["extra"]=> string(0) "" ["_modulename"]=> string(4) "News" ["_eventname"]=> string(16) "NewsArticleAdded" } 


Lise (Blog)
I want to change summary and content

Code: Select all


array(3) { ["item_object"]=> &object(LISEItem)#430 (15) { ["item_id"]=> int(-1) ["alias"]=> string(6) "dsfdsf" ["title"]=> string(6) "dsfdsf" ["url"]=> string(6) "dsfdsf" ["position"]=> int(-1) ["active"]=> int(1) ["create_time"]=> string(0) "" ["modified_time"]=> string(0) "" ["start_time"]=> string(0) "" ["end_time"]=> string(0) "" ["owner"]=> NULL ["key1"]=> NULL ["key2"]=> NULL ["key3"]=> NULL ["fielddefs"]=> object(LISEFielddefArray)#472 (2) { ["_parent_item":"LISEFielddefArray":private]=> *RECURSION* ["storage":"ArrayObject":private]=> array(7) { [1]=> object(lisefd_TextArea)#474 (21) { ["id":protected]=> string(1) "1" ["name":protected]=> string(7) "Summary" ["alias":protected]=> string(7) "summary" ["description":protected]=> string(0) "" ["type":protected]=> string(8) "TextArea" ["friendlytype":protected]=> string(9) "Text Area" ["value":protected]=> object(LISEFielddefValue)#426 (1) { ["storage":"ArrayObject":private]=> array(1) { [0]=> string(15) "

text suff
" } } ["originator":protected]=> string(4) "LISE" ["active":protected]=> bool(true) ["disabled":protected]=> bool(false) ["path":protected]=> string(69) "/home/sheffieldvoices/public_html/modules/LISE/lib/fielddefs/TextArea" ["position":protected]=> string(1) "0" ["required":protected]=> string(1) "0" ["options":protected]=> array(3) { ["max_length"]=> string(4) "1000" ["search_index"]=> string(1) "1" ["wysiwyg"]=> string(1) "1" } ["caller":protected]=> NULL ["item_id":protected]=> int(-1) ["parent_array":protected]=> *RECURSION* ["template":protected]=> string(35) "{$fielddef.name}: {$fielddef.value}" ["view":protected]=> NULL ["hastemplate":protected]=> bool(true) ["event_handler":protected]=> object(LISEEventHandlerBase)#489 (1) { ["_field":"LISEEventHandlerBase":private]=> *RECURSION* } } [2]=> object(lisefd_TextArea)#475 (21) { ["id":protected]=> string(1) "2" ["name":protected]=> string(7) "Content" ["alias":protected]=> string(7) "content" ["description":protected]=> string(0) "" ["type":protected]=> string(8) "TextArea" ["friendlytype":protected]=> string(9) "Text Area" ["value":protected]=> object(LISEFielddefValue)#427 (1) { ["storage":"ArrayObject":private]=> array(1) { [0]=> string(15) "
text suff
" } } ["originator":protected]=> string(4) "LISE" ["active":protected]=> bool(true) ["disabled":protected]=> bool(false) ["path":protected]=> string(69) "/home/sheffieldvoices/public_html/modules/LISE/lib/fielddefs/TextArea" ["position":protected]=> string(1) "1" ["required":protected]=> string(1) "1" ["options":protected]=> array(3) { ["max_length"]=> string(4) "6000" ["search_index"]=> string(1) "0" ["wysiwyg"]=> string(1) "1" } ["caller":protected]=> NULL ["item_id":protected]=> int(-1) ["parent_array":protected]=> *RECURSION* ["template":protected]=> string(35) "{$fielddef.name}: {$fielddef.value}" ["view":protected]=> NULL ["hastemplate":protected]=> bool(true) ["event_handler":protected]=> object(LISEEventHandlerBase)#490 (1) { ["_field":"LISEEventHandlerBase":private]=> *RECURSION* } } [3]=> object(lisefd_Dropdown)#476 (21) { ["id":protected]=> string(1) "3" ["name":protected]=> string(6) "Status" ["alias":protected]=> string(6) "status" ["description":protected]=> string(0) "" ["type":protected]=> string(8) "Dropdown" ["friendlytype":protected]=> string(8) "Dropdown" ["value":protected]=> object(LISEFielddefValue)#429 (1) { ["storage":"ArrayObject":private]=> array(1) { [0]=> string(9) "published" } } ["originator":protected]=> string(4) "LISE" ["active":protected]=> bool(true) ["disabled":protected]=> bool(false) ["path":protected]=> string(69) "/home/sheffieldvoices/public_html/modules/LISE/lib/fielddefs/Dropdown" ["position":protected]=> string(1) "2" ["required":protected]=> string(1) "1" ["options":protected]=> array(1) { ["options"]=> string(32) "Published=published Draft=draft" } ["caller":protected]=> NULL ["item_id":protected]=> int(-1) ["parent_array":protected]=> *RECURSION* ["template":protected]=> string(35) "{$fielddef.name}: {$fielddef.value}" ["view":protected]=> NULL ["hastemplate":protected]=> bool(true) ["event_handler":protected]=> object(LISEEventHandlerBase)#491 (1) { ["_field":"LISEEventHandlerBase":private]=> *RECURSION* } } [7]=> object(lisefd_SelectDateTime)#477 (21) { ["id":protected]=> string(1) "7" ["name":protected]=> string(9) "Post Date" ["alias":protected]=> string(4) "date" ["description":protected]=> string(0) "" ["type":protected]=> string(14) "SelectDateTime" ["friendlytype":protected]=> string(15) "Select DateTime" ["value":protected]=> object(LISEFielddefValue)#473 (1) { ["storage":"ArrayObject":private]=> array(1) { [0]=> string(0) "" } } ["originator":protected]=> string(4) "LISE" ["active":protected]=> bool(true) ["disabled":protected]=> bool(false) ["path":protected]=> string(75) "/home/sheffieldvoices/public_html/modules/LISE/lib/fielddefs/SelectDateTime" ["position":protected]=> string(1) "3" ["required":protected]=> string(1) "0" ["options":protected]=> array(6) { ["backwards_compatibility"]=> string(1) "1" ["date_format"]=> string(8) "dd-mm-yy" ["format_type"]=> string(1) "1" ["show_seconds"]=> string(1) "0" ["size"]=> string(2) "20" ["time_format"]=> string(5) "HH:mm" } ["caller":protected]=> NULL ["item_id":protected]=> int(-1) ["parent_array":protected]=> *RECURSION* ["template":protected]=> string(51) "{$fielddef.name}: {$fielddef.value|cms_date_format}" ["view":protected]=> NULL ["hastemplate":protected]=> bool(true) ["event_handler":protected]=> object(liseeh_SelectDateTime)#492 (1) { ["_field":"LISEEventHandlerBase":private]=> *RECURSION* } } [10]=> object(lisefd_FileUpload)#478 (21) { ["id":protected]=> string(2) "10" ["name":protected]=> string(12) "Image upload" ["alias":protected]=> string(10) "FileUpload" ["description":protected]=> string(0) "" ["type":protected]=> string(10) "FileUpload" ["friendlytype":protected]=> string(11) "File Upload" ["value":protected]=> object(LISEFielddefValue)#494 (1) { ["storage":"ArrayObject":private]=> array(1) { [0]=> string(13) "logoLGBTQ.png" } } ["originator":protected]=> string(4) "LISE" ["active":protected]=> bool(true) ["disabled":protected]=> bool(false) ["path":protected]=> string(71) "/home/sheffieldvoices/public_html/modules/LISE/lib/fielddefs/FileUpload" ["position":protected]=> string(1) "4" ["required":protected]=> string(1) "1" ["options":protected]=> array(4) { ["allowed"]=> string(16) "gif,jpeg,jpg,png" ["dir"]=> string(11) "images/blog" ["image"]=> string(1) "1" ["size"]=> string(2) "20" } ["caller":protected]=> NULL ["item_id":protected]=> int(-1) ["parent_array":protected]=> *RECURSION* ["template":protected]=> string(99) "{$fielddef.name}: {$fielddef.value}" ["view":protected]=> NULL ["hastemplate":protected]=> bool(true) ["event_handler":protected]=> object(liseeh_FileUpload)#493 (2) { ["_data":"liseeh_FileUpload":private]=> array(5) { ["name"]=> string(13) "logoLGBTQ.png" ["type"]=> string(9) "image/png" ["tmp_name"]=> string(14) "/tmp/phpeEP2Ha" ["error"]=> int(0) ["size"]=> int(35690) } ["_field":"LISEEventHandlerBase":private]=> *RECURSION* } } [9]=> object(lisefd_TextInput)#479 (21) { ["id":protected]=> string(1) "9" ["name":protected]=> string(22) "Alternate Text (Image)" ["alias":protected]=> string(3) "alt" ["description":protected]=> string(0) "" ["type":protected]=> string(9) "TextInput" ["friendlytype":protected]=> string(10) "Text Input" ["value":protected]=> object(LISEFielddefValue)#482 (1) { ["storage":"ArrayObject":private]=> array(1) { [0]=> string(9) "gfhfgh gf" } } ["originator":protected]=> string(4) "LISE" ["active":protected]=> bool(true) ["disabled":protected]=> bool(false) ["path":protected]=> string(70) "/home/sheffieldvoices/public_html/modules/LISE/lib/fielddefs/TextInput" ["position":protected]=> string(1) "5" ["required":protected]=> string(1) "1" ["options":protected]=> array(3) { ["max_length"]=> string(3) "255" ["search_index"]=> string(1) "0" ["size"]=> string(2) "50" } ["caller":protected]=> NULL ["item_id":protected]=> int(-1) ["parent_array":protected]=> *RECURSION* ["template":protected]=> string(35) "{$fielddef.name}: {$fielddef.value}" ["view":protected]=> NULL ["hastemplate":protected]=> bool(true) ["event_handler":protected]=> object(LISEEventHandlerBase)#481 (1) { ["_field":"LISEEventHandlerBase":private]=> *RECURSION* } } [5]=> object(lisefd_TextInput)#480 (21) { ["id":protected]=> string(1) "5" ["name":protected]=> string(12) "Extra (Code)" ["alias":protected]=> string(4) "code" ["description":protected]=> string(0) "" ["type":protected]=> string(9) "TextInput" ["friendlytype":protected]=> string(10) "Text Input" ["value":protected]=> object(LISEFielddefValue)#483 (1) { ["storage":"ArrayObject":private]=> array(1) { [0]=> string(0) "" } } ["originator":protected]=> string(4) "LISE" ["active":protected]=> bool(true) ["disabled":protected]=> bool(false) ["path":protected]=> string(70) "/home/sheffieldvoices/public_html/modules/LISE/lib/fielddefs/TextInput" ["position":protected]=> string(1) "6" ["required":protected]=> string(1) "0" ["options":protected]=> array(3) { ["max_length"]=> string(3) "255" ["search_index"]=> string(1) "0" ["size"]=> string(3) "100" } ["caller":protected]=> NULL ["item_id":protected]=> int(-1) ["parent_array":protected]=> *RECURSION* ["template":protected]=> string(35) "{$fielddef.name}: {$fielddef.value}" ["view":protected]=> NULL ["hastemplate":protected]=> bool(true) ["event_handler":protected]=> object(LISEEventHandlerBase)#495 (1) { ["_field":"LISEEventHandlerBase":private]=> *RECURSION* } } } } } ["_modulename"]=> string(8) "LISEblog" ["_eventname"]=> string(11) "PreItemSave" } 
andrewvideouk
Forum Members
Forum Members
Posts: 155
Joined: Thu Aug 20, 2020 10:49 pm

Re: Event manger with modules

Post by andrewvideouk »

Look like i well have to hack the news, CGCalendar and lise. I can't get to work with EventEditedPre, PreItemSave and NewsArticleAdded in the event manger.
I really need to edit the conent before its saved to database. So I will hack the modules I know not the right way but I have only few weeks to get this site done and only way to get to work. I have the php function working nice with conent pages so be 2 mins job instert function in the modules.
Post Reply

Return to “CMSMS Core”