Вывод тегов для отдельной страницы
Материал из Umicms
Версия от 13:27, 5 июня 2013; Mad grant (обсуждение | вклад)
Ниже приведен сам скрипт который мы вставляем в classes/modules/custom.php
public function tags_out($id=NULL,$template=
NULL) {
if(!$id) return;
$hierarchy = umiHierarchy::getInstance();
$element = $hierarchy->getElement($id);
if(!$element) return;
if(!$template) $template="tags";
list($tpl_tags, $tpl_tag, $tpl_tag_sep, $tpl_tags_empty) = def_module::loadTemplates("tpls/content/".$template.".tpl","cloud_tags","cloud_tag","cloud_tagseparator","cloud_tags_empty");
$mas=array();
$resou='';
$s_prefix='Account';
$mas=$element->getValue("tags");
$sz=sizeof($mas);
if($sz>0){
$arrTagsTplteds = array();
for($i=0;$i<$sz;$i++){
$params = array(
'tag'=>$mas[$i],
'tag_urlencoded'=>rawurlencode($mas[$i]),
'attribute:weight' => '',
'attribute:font' => '',
'attribute:context' => $s_prefix
);
$arrTagsTplteds[] = def_module::parseTemplate($tpl_tag, $params);
}
if (isset($arrTagsTplteds[0]) && is_array($arrTagsTplteds[0])) { // udata
$arrForTags = array('subnodes:items'=>$arrTagsTplteds);
} else {
$arrForTags = array('items'=>implode($tpl_tag_sep, $arrTagsTplteds));
}
$arrForTags['attribute:summ_weight'] = '';
$arrForTags['attribute:context'] = $s_prefix;
return def_module::parseTemplate($tpl_tags, $arrForTags);
}else {
$arrForTags = array();
return def_module::parseTemplate($tpl_tags_empty, $arrForTags);
}
}
А затем в нужном на месте выводим теги вставляя в шаблон %custom tags_out(%id%)%. Следует также помнить, что у вас должны быть шаблон для макроса %content pagesByAccountTags()%, так как именно через него ссылка открывает вам список страниц, содержащих такой тег. В случае если вы используете tpl шаблонизатор, то это файл tpls/content/tags.tpl Источник http://umihelp.ru/