I have some code on PHP something like:
$oldstring = ...;
...
$pattern = ...;
$newstring = preg_replace_callback($pattern, ... {...}, $oldstring);
echo $newstring;
I need to apply this code (maybe as class or somehow) to content of component and each existing module on the page, something like:
$doc = JFactory::getDocument();
$oldcomponent = $doc->getBuffer('component', '', array('class'=> ''));
// the same code for applying
echo $newcomponent;
$oldmodule1 = $doc->getBuffer('modules', 'position-1', array('style'=> ''));
// the same code for applying
echo $newmodule1;
$oldmodule2 = $doc->getBuffer('modules', 'position-2', array('style'=> ''));
// the same code for applying
echo $newmodule2;
...
$oldmoduleN = $doc->getBuffer('modules', 'position-N', array('style'=> ''));
// the same code for applying
echo $newmoduleN;
The second code is only something like what I mean. I.e. as old strings should be component and each module and they should be echoed as new strings on its positions on the page.
Can someone write example how to create simple Joomla plugin for this purpose. Thanks