/** * The "replaceInsertTags" hook is triggered when an unknown insert tag is * found. It passes the insert tag as argument and expects the replacement * value or "false" as return value. * * anystores::details:[ID] * anystores::count:[CategoryID|all] * * @todo * anystores:phone:[ID] * anystores:fax:[ID] * ... * * @param string $strTag * @return bool | string */ public function replaceInsertTagsHook($strTag) { $arrElements = explode('::', $strTag); if ($arrElements[0] != 'anystores') { return false; } $arrKeys = explode(':', $arrElements[1]); try { switch ($arrKeys[0]) { // get store details case 'details': if (($objStore = AnyStoresModel::findPublishedByIdOrAlias($arrKeys[1])) !== null) { // Location template $objLocationTemplate = new \FrontendTemplate('anystores_details'); $objLocationTemplate->setData($objStore->loadDetails()->row()); // Module template $objModuleTemplate = new \FrontendTemplate('mod_anystores_inserttag'); $objModuleTemplate->store = $objLocationTemplate; // Parse module template $strTemplate = $objModuleTemplate->parse(); $strTemplate = $this->replaceInsertTags($strTemplate); return $strTemplate; } return false; // count category items // count category items case 'count': if ($arrKeys[1] == 'all') { return AnyStoresModel::countAllPublished(); } else { return AnyStoresModel::countPublishedByPid($arrKeys[1]); } default: return false; } } catch (\Exception $e) { \System::log('Replace insert tag error: ' . $e->getMessage(), __METHOD__, TL_ERROR); } return false; }