Extra functions when adding pages of a certain page type
Permalink 1 user found helpful
Hello,
I was wondering, is it possible to add extra functions when adding a page of a certain page type. Something the add.php does for a block.
In my case i want To be able To select a record from a table To populate the attributes assigned to that page type with the values of that record.
Thanks for your input
Gr. Marco
I was wondering, is it possible to add extra functions when adding a page of a certain page type. Something the add.php does for a block.
In my case i want To be able To select a record from a table To populate the attributes assigned to that page type with the values of that record.
Thanks for your input
Gr. Marco
Have you tried hooking into the on_page_add event, and setting the attribute values there? I'm not sure if this works though, since the page might not actually be added until after the properties dialog is saved. (But I don't know of any other way to accomplish this).
Thanks for the push in the right direction Jordan,
i've already learned a lot about C5 the last 20 months and your posts in the forums already helped me in the past.
i'll addhttp://www.concrete5.org/documentation/developers/system/events... to my 'next thing to learn about C5' list.
thanks again
Gr. Marco
ps: would you mind taking a look at an unanswered post of mine:
http://www.concrete5.org/community/forums/customizing_c5/sort-order...
i've already learned a lot about C5 the last 20 months and your posts in the forums already helped me in the past.
i'll addhttp://www.concrete5.org/documentation/developers/system/events... to my 'next thing to learn about C5' list.
thanks again
Gr. Marco
ps: would you mind taking a look at an unanswered post of mine:
http://www.concrete5.org/community/forums/customizing_c5/sort-order...
Ok Jordan,
i've started with your tutorial
http://www.concrete5.org/documentation/how-tos/developers/get-email...
modified it to perform the tasks i need and it works !!!
i'm also trying to put everything i create in a package, but when i try to put the event files in my package the events don't work anymore
in my site i added
/config/site_events.php
/libraries/page_added.php
this situation works
but
when i move these files to the same locations in my package it stops working
/packages/my_package/config/site_events.php
/packages/my_package/libraries/page_added.php
do i need to add anything in the package controller.php to get this working from within the package?
thanks
Gr. Marco
i've started with your tutorial
http://www.concrete5.org/documentation/how-tos/developers/get-email...
modified it to perform the tasks i need and it works !!!
i'm also trying to put everything i create in a package, but when i try to put the event files in my package the events don't work anymore
in my site i added
/config/site_events.php
/libraries/page_added.php
this situation works
but
when i move these files to the same locations in my package it stops working
/packages/my_package/config/site_events.php
/packages/my_package/libraries/page_added.php
do i need to add anything in the package controller.php to get this working from within the package?
thanks
Gr. Marco
I had allready put this line in my site.php, otherwise my the site events didn't work when i put them in the root of my site. Now i also added it to the controller.php of my package
i get a feeling i miss a step because when i put a
in my
/config/site_events.php
the site dies, but when i put the same
in my
/packages/my_package/config/site_events.php
the site doesn't die, this makes me believe this file is ignored by Concrete, probably because i missed a step?
i get a feeling i miss a step because when i put a
die("test");
in my
/config/site_events.php
the site dies, but when i put the same
die("test");
in my
/packages/my_package/config/site_events.php
the site doesn't die, this makes me believe this file is ignored by Concrete, probably because i missed a step?
There is no such thing as /packages/my_package/config/site_events.php -- that file will never be looked at by the C5 system. The site_events.php file *only* works from your site's top-level "config" directory.
To hook into events from packages, you need to call Events::extend(...) from the package on_start method (like you do in your subsequent response).
Sorry I didn't make this clearer in my earlier answer, but glad you finally figured it out.
To hook into events from packages, you need to call Events::extend(...) from the package on_start method (like you do in your subsequent response).
Sorry I didn't make this clearer in my earlier answer, but glad you finally figured it out.
Ok,
i did some further digging and found the answer in the next thread
http://www.concrete5.org/community/forums/customizing_c5/uninstalli...
in the on_start method you mentioned the event should also be placed
something like this
instead of putting it in
/packages/my_package/config/site_events.php
this is not described in the
http://www.concrete5.org/documentation/developers/system/events...
page (or i missed it)
Thanks for the help, case closed for now :)
i did some further digging and found the answer in the next thread
http://www.concrete5.org/community/forums/customizing_c5/uninstalli...
in the on_start method you mentioned the event should also be placed
something like this
instead of putting it in
/packages/my_package/config/site_events.php
this is not described in the
http://www.concrete5.org/documentation/developers/system/events...
page (or i missed it)
Thanks for the help, case closed for now :)