registerEvent('onPrepareContent', 'botJoomfishAlternative'); function botJoomfishAlternative( &$row, &$params, $page=0 ) { // simple performance check to determine whether bot should process further if ( strpos( $row->text, 'jfalternative' ) === false ) { return true; } // define the regular expression for the bot $regex = "#{jfalternative}(.*?){/jfalternative}#s"; preg_match($regex, $row->text, $matches); if (count($matches)!=2) return true; list($id,$table,$defaultText) = explode("|",$matches[1]); // only support tables at this time. if ($table!="content"){ $row->text = preg_replace( $regex, '', $row->text ); return true; } $db = JFactory::getDBO(); $sql = "SELECT DISTINCT jfl.shortcode, jfl.iso, jfl.name, jfl.image FROM #__jf_content AS jfc, #__languages AS jfl " ."\n WHERE reference_id=$id AND reference_table='".$table."'" ."\n AND jfc.language_id=jfl.id AND jfc.published=1"; $db->setQuery($sql); $alts = $db->loadObjectList(); if (is_array($alts) && count($alts)>0){ $alttext = "