Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Displaying category description
Tudor
✭
How can I display the categories descriptions in the category list?
And also on the category page?
And also on the category page?
0
Comments
- Create a custom theme
- You have to customize a "views" file (see the Theme QuickStart page). In this case it's /applications/vanilla/discussions/helper_functions.php. You don't have to modify the original one, just copy it into /themes/Your_Custom_Theme/views/discussions/helper_functions.php.
- Somewhere around line 100 you'll see this:
if (property_exists($Sender, 'Category') && is_object($Sender->Category)) { ?> <div class="SubTab">↳ <?php echo $Sender->Category->Name; ?></div> <?php }
I replaced it with this:
if (property_exists($Sender, 'Category') && is_object($Sender->Category)) { ?> <h2 class="DTPCategoryName"><?php echo $Sender->Category->Name; ?></h2><p class="DTPCategoryDesc"><?php echo $Sender->Category->Description; ?></p> <?php } ?>
And you can see the result here.
- Create a custom theme
- You have to customize a "views" file (see the Theme QuickStart page). In this case it's /applications/vanilla/discussions/helper_functions.php. You don't have to modify the original one, just copy it into /themes/Your_Custom_Theme/views/discussions/helper_functions.php.
- Somewhere around line 100 you'll see this:
if (property_exists($Sender, 'Category') && is_object($Sender->Category)) { ?> <div class="SubTab">↳ <?php echo $Sender->Category->Name; ?></div> <?php }
I replaced it with this:
if (property_exists($Sender, 'Category') && is_object($Sender->Category)) { ?> <h2 class="DTPCategoryName"><?php echo $Sender->Category->Name; ?></h2><p class="DTPCategoryDesc"><?php echo $Sender->Category->Description; ?></p> <?php } ?>
And you can see the result here.
And remove all the < br / > from the code, they were inserted by the forum here (< code > tag parsing bugs?)
Gdn_Format::To($sender->Category->Description, 'markdown')
This allows *markdown* to be _used_ in the description to tart it up a bit, avoiding the need to add HTML tags (which affect the admin views of the categories).
would have been great. but the code has changed. helper_functions.php is no longer what it used to be :-(
aarch you 're right... I can't find this suggested code in the latest v2.0.18.4
Nobody could help us? thanks in advance
yea trying to do that in the latest 2.1 version.... codes are not hte same
I stumbled upon this from Google, thought I'd update it for anyone wanting to know.
File to edit: /vanilla/views/categories/discussions.php
+22: <div><?php echo $Category->Description; ?></div>
That's all I had to add to get mine to work, you can also add this file as a view to your theme with the same structured layout as above (/vanilla/themes/[name]/views/categories/discussions.php). Hope this helps someone, this is for version 2.1.2 and it should be pretty self explanatory after opening that file.
Thanks
just a thought, might be cleaner with a theme hook checking the AfterCategoryTitle event.
then you can avoid changing view.
on the categories discussions page. descriptions seem to show elsewhere without any changes.
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
although it might be better if the event were moved out of the h2 tag
to
otherwise you would probably need to close the h2 tag and reopen in the insertion to avoid doing getting the description as part of h2
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.