Page 1 of 1
Get and replace content_page before sending to browser with UDT
Posted: Mon Mar 10, 2008 12:21 pm
by Sonya
Hello,
I am trying to write an UDT which gets the smarty parsed content just before sending it to browser and replace some words with links. Something like this:
Code: Select all
global $gCms;
$pagecontent = str_replace('word','<a href="#">word</a>',$pagecontent);
My problem is: I do not know how to get parsed page content of the actual page in my UDT. In my example the variable I'm looking for is $pagecontent.
Thank you for your help.
Sonya
Re: Get and replace content_page before sending to browser with UDT
Posted: Mon Mar 10, 2008 8:43 pm
by alby
Sonya wrote:
My problem is: I do not know how to get parsed page content of the actual page in my UDT. In my example the variable I'm looking for is $pagecontent.
Many option:
1:
- create a modifier smarty (view smarty doc)
2:
- capture {content} and assign to smarty variable
- pass this variable to your UDT
3:
- use CGSimpleSmarty for retrive content and assign
- pass this variable to your UDT
Alby
Re: Get and replace content_page before sending to browser with UDT
Posted: Mon Mar 10, 2008 8:47 pm
by calguy1000
No, the best way to do it is to have a UDT that handles the ContentPostRender event. I think this could do it.
Re: Get and replace content_page before sending to browser with UDT
Posted: Tue Mar 11, 2008 12:06 am
by Sonya
alby wrote:
- create a modifier smarty (view smarty doc)
Thank you. I've created modifier.link.php in /plugins directory of my project:
Code: Select all
function smarty_cms_modifier_link($string)
{
return str_replace('word','<a href="#">word</a>',$string);
}
Then use the content tag in my theme with modifier:
It works

Re: Get and replace content_page before sending to browser with UDT
Posted: Tue Mar 11, 2008 12:10 am
by Sonya
calguy1000 wrote:
No, the best way to do it is to have a UDT that handles the ContentPostRender event. I think this could do it.
calguy100, I can assign UTD to event. But how can I handle an event with UDT?