Need to move tag/indicator from meta to title
![Zhaan](https://us.v-cdn.net/5018160/uploads/userpics/589/nULOBV8X4LB8S.png)
Hiya, hope y'all had a good xmas & NYE!
As for my problem -- I want to move the "tag" indicator ("Announcement", "Closed", etc.) from the discussion meta field to the actual discussion title. I basically want it to look like this:
[Closed] This is a very important topic title.
I've been digging around inside views/discussions/helper_functions.php, but I'm not quite sure what to do. Could any of you guys help me out?
Using 2.1.7, default theme. Any help will be appreciated!
Best Answers
-
R_J Admin
Look at this plugin in order to see how you can put something before a discussion title: http://vanillaforums.org/addon/prefixdiscussion-plugin
You basically just have to check if a discussion is an announcement and then prefix it like that. I don't know how to prevent the regular "Announcement" strings without looking at the code right now, but you might want to start with the discussion title
6 -
peregrine MVP
@Zhaan - here is a third option. not sure what your goal is. space or highlighting.
removes announcement and close meta tags. puts a span headmine above announcement.
modify css as you desire based on classes in span in plugin e.g. .Announcement-Alert
you could add this to your custom.css
.Item.Announcement { background-color: red; } span.Tag.Tag-Announcement, span.Tag.Tag-Closed { display:none; } .Announcement-Alert { background-color: green; }
and this plugin
plugins/AnnouncementAlert/default.php
<?php if(!defined('APPLICATION')) die(); $PluginInfo['AnnouncementAlert'] = array( 'Version' => '1.0', 'Name' => 'AnnouncementAlert', 'Description' => 'Place a Label above Announcement to highlight and use custom.css', 'MobileFriendly' => TRUE, 'Author' => 'p' ); class AnnouncementAlertPlugin extends Gdn_Plugin { public function DiscussionsController_BeforeDiscussionName_Handler($Sender) { $Discussion = $Sender->EventArguments["Discussion"]; if(val('Announce', $Discussion) >= 1) { echo wrap(wrap(T("Please Read The Announcement below very important"), 'h1 span', array('class' => "Announcement-Alert")), 'li'); } } public function CategoriesController_BeforeDiscussionName_Handler($Sender) { $Discussion = $Sender->EventArguments["Discussion"]; if(val('Announce', $Discussion) >= 1) { echo wrap(wrap(T("Please Read The Announcement below very important"), 'h1 span', array('class' => "Announcement-Alert")), 'li'); } } }
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
6 -
R_J Admin
CSS is the most easiest way. You can also overwrite the function WriteTags. That's the original code:
function WriteTags($Discussion) { Gdn::Controller()->FireEvent('BeforeDiscussionMeta'); echo Tag($Discussion, 'Announce', 'Announcement'); echo Tag($Discussion, 'Closed', 'Closed'); Gdn::Controller()->FireEvent('AfterDiscussionLabels'); }
If you are already writing a custom plugin, you can also add that lines at the very end of your custom plugin (even after the closing bracket of your custom plugin class!)
function WriteTags($Discussion) { Gdn::Controller()->FireEvent('BeforeDiscussionMeta'); Gdn::Controller()->FireEvent('AfterDiscussionLabels'); }
7
Answers
Look at this plugin in order to see how you can put something before a discussion title: http://vanillaforums.org/addon/prefixdiscussion-plugin
You basically just have to check if a discussion is an announcement and then prefix it like that. I don't know how to prevent the regular "Announcement" strings without looking at the code right now, but you might want to start with the discussion title
if you are going to go with r_j's plugin. which would be the simplest way to do it.
then just use css element focus in on class to hide the Tag with a display:none
Tag-Announcement
do the same thing with Closed.
the other way you could do it is via your own plugin
and check for Announcements,,,,
perhaps in Discussion name handler
add css to remove tag.
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
@Zhaan - here is a third option. not sure what your goal is. space or highlighting.
removes announcement and close meta tags. puts a span headmine above announcement.
modify css as you desire based on classes in span in plugin e.g. .Announcement-Alert
you could add this to your custom.css
and this plugin
plugins/AnnouncementAlert/default.php
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
CSS is the most easiest way. You can also overwrite the function WriteTags. That's the original code:
If you are already writing a custom plugin, you can also add that lines at the very end of your custom plugin (even after the closing bracket of your custom plugin class!)
yes it depends on his ultimate reason for doing what he wants to do.
r_j - you didn't like my xmas effect![:wink: :wink:](https://open.vanillaforums.com/plugins/emojiextender/emoji/little/wink.png)
could change it to the colors of your country flag![:) :)](https://open.vanillaforums.com/plugins/emojiextender/emoji/little/smile.png)
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
It definitely needs some reindeers![;) ;)](https://open.vanillaforums.com/plugins/emojiextender/emoji/little/wink.png)
.
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
Thank you all for your input!