text, 'fussballergebnisse') === false) { return true; } // Search for expression 'fussballergebnisse' $regex = '/{fussballergebnisse\s(.*?)}/i'; // Find all instances of plugin and put in $matches for loadposition // $matches[0] is full pattern match, $matches[1] is the position preg_match_all($regex, $article->text, $matches, PREG_SET_ORDER); // Are there any matches? if ($matches) { //load javascript from www.fussball.de $document = JFactory::getDocument(); $document->addScript('https://www.fussball.de/static/layout/fbde2/egm//js/widget2.js'); //we need a counter for multiple widgets $counter = 1; foreach ($matches as $match) { $matcheslist = explode(',', $match[1]); if(count($matcheslist)){ //now we have the code $code = $matcheslist[0]; // Generate random counter in order to diff between multiple plugin references on the same page $randomID = rand(1,1000); //widgetcode for widget-id $html = '
'; //replace the pattern with the html code $article->text = preg_replace("|".$match[0]."|", addcslashes($html, '\\$'), $article->text, 1); } //next widget $counter++; } } } } ?>