Show tags under discussion title
Best Answers
-
Kastang New
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.
0 -
Kastang New
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> ";
0 -
Kastang New
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">
1
Answers
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.
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');
There was an error rendering this rich post.
Strike that it does work ! Apologies...
There was an error rendering this rich post.
Would be nice to make them clickable.
There was an error rendering this rich post.
Somehow think i need to use this:
There was an error rendering this rich post.
So need to:
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
There was an error rendering this rich post.
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> ";
hahah you are good. Cheers. Will get styling, and post screeny soon. Cheers !!!
There was an error rendering this rich post.
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:
`
`
Do you know what the code would be to also add tags to first post in thread ?
There was an error rendering this rich post.
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">
@kastang i will try this first thing in the mornng, thanks mate
There was an error rendering this rich post.
@kastang , works perfectly. Small adjustment to String, and its perfect. Thanks.
There was an error rendering this rich post.
@kastang
I was looking for this as well. But I don't see
<div class="CommentInfo">
in helper_functions.phpHas 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.