Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID Sign In with Twitter

Categories

In this Discussion

Who's Online 10

CurtisOdenericgillettefh111tc74 +6 guests

Show tags under discussion title

Is there a way of showing tags created for a thread, under the discussions title on main forum index page ?

♥ I love Vanilla. VanillaSkins | on Twitter | on Facebook | Available Freelance | Take the Vanilla Test | Free Downloads

Tagged:

Comments

  • Posts: 14 Accepted Answer

    If you copy

    /applications/vanilla/views/discussions/helper_functions.php

    to

    /themes/[YOURTHEME]/views/discussions/helper_functions.php

    you can add the tags string to the discussions by adding:

    if($Discussion->Tags != '') { echo '<span class="DiscussionTags">Tags: '.$Discussion->Tags.'</span>'; }

    directly before

    $Sender->FireEvent('DiscussionMeta');

    located at the bottom of the file.

  • 422422
    Posts: 2,109

    Tried that, but does not display:

    I have:

    if (C('Vanilla.Categories.Use') && $Discussion->CategoryUrlCode != '')
                   echo Wrap(Anchor($Discussion->Category, '/categories/'.rawurlencode($Discussion->CategoryUrlCode), 'Category'));
                if($Discussion->Tags != '') { echo 'Tags: '.$Discussion->Tags.''; }
                $Sender->FireEvent('DiscussionMeta');

    ♥ I love Vanilla. VanillaSkins | on Twitter | on Facebook | Available Freelance | Take the Vanilla Test | Free Downloads

  • 422422
    Posts: 2,109

    Strike that it does work ! Apologies...

    ♥ I love Vanilla. VanillaSkins | on Twitter | on Facebook | Available Freelance | Take the Vanilla Test | Free Downloads

  • 422422
    Posts: 2,109

    Would be nice to make them clickable.

    ♥ I love Vanilla. VanillaSkins | on Twitter | on Facebook | Available Freelance | Take the Vanilla Test | Free Downloads

  • 422422
    Posts: 2,109

    Somehow think i need to use this:

    Anchor(htmlspecialchars($Tag->Name), 'discussions/tagged/'.urlencode($Tag->Name))

    ♥ I love Vanilla. VanillaSkins | on Twitter | on Facebook | Available Freelance | Take the Vanilla Test | Free Downloads

  • 422422
    Posts: 2,109

    So need to:

    1. wrap each tag in span class.
    2. add url to each tag ( so can be clicked )

    SO far I have.

    if($Discussion->Tags != '') { echo ''.$Discussion->Tags.''; }

    Obviously, the tagWrap wraps all tags, not each tag with css. So need to fix that. Also need to add url to each tag

    ♥ I love Vanilla. VanillaSkins | on Twitter | on Facebook | Available Freelance | Take the Vanilla Test | Free Downloads

  • Posts: 14 Accepted Answer

    Try this:

    if($Discussion->Tags != '') { $Tags = explode(' ',$Discussion->Tags); $String = ""; foreach($Tags as $t) { $String .= "<a href='index.php?p=discussions/tagged/".rawurlencode($t)."'>$t</a> "; } echo '<span class="DiscussionTags">Tags: '.$String.'</span>'; }

    The above is assuming you are NOT using URL Rewriting. If you are, change the $String variable in the foreach loop to:

    $String .= "<a href='discussions/tagged/".rawurlencode($t)."'>$t</a> ";

  • 422422
    Posts: 2,109

    hahah you are good. Cheers. Will get styling, and post screeny soon. Cheers !!!

    ♥ I love Vanilla. VanillaSkins | on Twitter | on Facebook | Available Freelance | Take the Vanilla Test | Free Downloads

  • Posts: 14 1 like

    For anyone in the future looking to do this; here is a slightly less hackish way that will automatically adjust for rewrite URLs being either on or off:

    `

             if($Discussion->Tags != '') {
                $Tags = explode(' ',$Discussion->Tags);
                $String = "";
                foreach($Tags as $t) {
                    $String .= "<a href='";
                    $String .= (strstr($Discussion->Url, "index.php?p=") ? "index.php?p=" : "");
                    $String .= "discussions/tagged/".rawurlencode($t)."'>$t</a> ";
                }
                echo '<span class="DiscussionTags">Tags: '.$String.'</span>';
            }
    

    `

  • 422422
    Posts: 2,109

    Do you know what the code would be to also add tags to first post in thread ?

    ♥ I love Vanilla. VanillaSkins | on Twitter | on Facebook | Available Freelance | Take the Vanilla Test | Free Downloads

  • Posts: 14 Accepted Answer 1 like

    Move:

    /applications/vanilla/views/discussion/helper_functions.php

    To:

    /themes/[YOURTHEME]/views/discussion/helper_functions.php

    Add:

    <? if($Sender->Discussion->Tags != '' && $Type != 'Comment') { $Tags = explode(' ',$Sender->Discussion->Tags); $String = ""; foreach($Tags as $t) { $String .= "<a href='"; $String .= (strstr($Sender->Form->Action, "index.php?p=") ? "index.php?p=" : ""); $String .= "discussions/tagged/".rawurlencode($t)."'>$t</a> "; } echo '<span class="DiscussionTags">Tags: '.$String.'</span>'; } ?>

    Directly Before:

    <div class="CommentInfo">

  • 422422
    Posts: 2,109

    @kastang i will try this first thing in the mornng, thanks mate

    ♥ I love Vanilla. VanillaSkins | on Twitter | on Facebook | Available Freelance | Take the Vanilla Test | Free Downloads

  • 422422
    Posts: 2,109

    @kastang , works perfectly. Small adjustment to String, and its perfect. Thanks.

    ♥ I love Vanilla. VanillaSkins | on Twitter | on Facebook | Available Freelance | Take the Vanilla Test | Free Downloads

  • @kastang

    I was looking for this as well. But I don't see <div class="CommentInfo"> in helper_functions.php

    Has it changed recently? Could you help me figure out where to insert this. I'm on Vanilla 2.0.18.3. Sorry I'm not a php developer. Thanks for your help.

Sign In or Register to comment.