Forums / Cotonti / Support / I want to control {TAGS_RESULT_ROW_TAGS}

I want to control the output of {TAGS_RESULT_ROW_TAGS}

Macik
#41666 2016-05-07 16:12

Unfortunly, there is no predefined method to extend `{TAGS_RESULT_ROW_TAGS}` generation process. As it not use resource strings as done for forum topic tags list with `tags_link_tag` resoure string.

In spite of that, we can use some tricks and try to do some customization. Let's see in `tags.php` file, line 239: 

if ($tag_i > 0) $tag_list .= ', ';
$tag_list .= cot_rc_link(cot_url('plug', array('e' => 'tags', 'a' => 'pages', 't' => str_replace(' ', '-', $tag_u), 'tl' => $tl)), htmlspecialchars($tag_t));
$tag_i++;

It's where acrual generation is done. This line goes within `foreach` loop.

`cot_rc_link` use predefined (built-in) string resource, so we can not alter it. Only we have it's a generated comma separated list of links...
So now there is only one way to customize it — to alter already genererated string with a callback function.
We can do it with own custom function, placed in `yourthemename.php` or `system/functions.custom.php`. And call it from our template:

{TAGS_RESULT_ROW_TAGS|my_tagslist_customization($this)} 

The function can look like this (I'm writing it without tests so fix it for your needs):

function my_tagslist_customization($tagslist)
{
  $items = preg_split('/\s*,\s*/', $tagslist);
  foreach ($items as &$item)
  {
     $item = preg_replace('>(\w+)</a>',' rel="tag"><span itemprops="keywords">$1</span></a>', $item);
  }
  return implode(',', $items);
}

Or you can do this right in template, example:

{TAGS_RESULT_ROW_TAGS|preg_replace('>(\w+?)</a>',' rel="taglink"><span itemprops="keywords">$1</span></a>',$this)}

 

https://github.com/macik
правильный хостинг — https://goo.gl/fjCa1F