After filtering entries, my URL looks like that:


I'm wondering what's the best way to get a list of those tags in a <ul>. I could build the functionality in PHP but I'm thinking this functionality might be built in already since it seems pretty standard and I'm just not seeing it in the docs?

Basically, what I want to do is list all the tags that have been selected like:

x tag01 x tag02 x tag03

And let the user remove whatever tags they want from the result by clicking on the x.

Thanks for any pointer in the right direction!

3 Answers 3


Wile I agree that it seems intuitive that Solspace would allow output to a list, it's not in there. It's simple enough to create your own, though, and the following code should get you up and running with the outputting of the tags:

<div class="entry_tags">
  <p><b>THIS ENTRY'S TAGS:</b>
    {exp:tag:tags entry_id="{entry_id}" [tag_group_name="your_tag_group"] backspace="2" orderby="tag_name" sort="asc" }
              {if tag_count == '1'}
      <ul class="tag_list">
      <li class="tag_list_item"><a href="#" class="close_box">X</a>&nbsp;[<a href="{path='your/path'}/{websafe_tag}/">]{tag}[</a>]</li>
              {if tag_count == tag_total_results}</ul>{if:else} {/if}

Now, you will still have to create CSS to format your list inline, and you will have to code your Javascript to act when that .close_box is clicked, but I'm not thinking you were asking for that code, were you?

Note: Items in square brackets are optional.


Thanks @dashard but that's not really what I needed. I guess my explanation wasn't clear enough. Sorry about that! I'm not showing one entry on the page. I'm showing all entries filtered by any number of tags, so my URI looks like that: mysite.com/template/tag/tag01:tag02:tag03and I'm showing all entries tagged with tag01 and tag02 and tag03. I want to have a list of the current "page filtering" so to speak, and let the user remove some of those tags in order to broaden the filtering if they want to.

I thought the functionality might be built in, that's why I asked… But it doesn't seem like it, so I just coded it up in PHP.

In case anyone is interested, that's how it looks like:

    // get the last URI segment
    $tag_segment = array_pop(explode("/", urldecode($_SERVER["REQUEST_URI"])));
    // put the tags in an array
    $tags = explode(":", $tag_segment);
    $tag_links = "";
    // loop through the tags
    foreach ($tags as $t) {
        // rebuild the tag URI segment with all tags but WITHOUT the current one
        // so when we click on a tag, it "removes" itself
        $tags_others = implode(":", array_diff($tags, array($t)));
        // build the tag list
        $tag_links .= '<li><a href="{path=tag}/'.str_replace(" ", "+", $tags_others).'">'.$t.'</a></li>';
<ul class="tags">

You could use {exp:tag:cloud} and provide a pipe-delimited list of your tags in the tag_name="" parameter: http://www.solspace.com/docs/tag/cloud/#tag_name You would need to search/replace colons : to pipes |. You can do this with PHP set to input:

   $tags = '{segment_3}'; // This is parsed early, before PHP 
   $tags = str_replace(':', '|', $tags);

{exp:tag:cloud tag_name="<?php echo $tags; ?>"}
   // Your list of tags

There might be add-ons that can do the same thing, and there is also embed templates that you could use to get around parse order.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.