php - Modify article on the fly in Joomla -
i can change title placing next line template:
$doc->settitle('my new title');
but method modify article's 'fulltext' in same way?
short answer: yes, content plugin.
details
if can use $doc->settitle()
, assume somewhere before line there's line says:
$doc = jfactory::getdocument();
but document refers whole page, you're setting html <title>
tag.
if want change article text, you're dealing result of specific component, i.e. com_content
, part of whole document.
there more 1 ways change it.
change whole page content
if want change whole page content in template, have do:
$buffer = $doc->getbuffer(); // ... whatever modification buffer $doc->setbuffer($buffer)
quite simple do, it's not idea put kind of logic in template (if ever want change template, you'll have copy / paste code).
use system plugin change buffer
the core of solution same before, put logic in system plugin, hooking on onafterrender
event. buffer, modify it, set buffer.
good solution simple modifications and/or if want make sure modifications applies any part of page.
use content plugin
a content plugin applies articles body, product descriptions, , similar text parts.
you should use if want modify parts.
Comments
Post a Comment