I'm trying to start creating plugins for Joomla, but the preg_replace counts for all php applications ofcourse.
For those who aren't confident with Joomla, this is my current code, which replaces every '{test}' in my article into 'test':
<?php
// no direct access
defined('_JEXEC') or die;
jimport('joomla.plugin.plugin');
class plgContentTest extends JPlugin
{
public function onContentPrepare($context, &$article, &$params, $page = 0)
{
// Simple performance check to determine whether bot should process further.
if (false === JString::strpos($article->text, '{test}')) {
return true;
}
// expression to search for searches
$regex = "^\{test}";
$article->text = preg_replace($regex, 'test', $article->text);
}
}
Now, I want to expand that.
Imagine that I have an article with in it 'blablabla {test}text{/test} blablabla'
How can I replace '{test}tekst{/test}' by 'test' without editing the rest?
The next step (for me) is tracking every '{test}text{/test}' and placing them into an array, then obtain 'text' from it, do something with that and then replace the whole '{test}text{/test}' with the thing I did with 'text'.
I hope you guys understand it
Thanks already

New Topic/Question
Reply




MultiQuote





|