To add the category description on the category page: - 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:
To add the category description on the category page: - 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:
I did this too, in the discussions view to show the description at the top of each category listing. I also did this to make formatting the description a little easier:
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).
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.
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.
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
<div class="CategoryBox Category-<?php echo $Category->UrlCode; ?>"> <h2 class="H"><?php echo Anchor(htmlspecialchars($Category->Name), CategoryUrl($Category)); Gdn::Controller()->EventArguments['Category'] = $Category; Gdn::Controller()->FireEvent('AfterCategoryTitle'); ?></h2>to
<div class="CategoryBox Category-<?php echo $Category->UrlCode; ?>"> <h2 class="H"><?php echo Anchor(htmlspecialchars($Category->Name), CategoryUrl($Category)); Gdn::Controller()->EventArguments['Category'] = $Category; ?></h2> <?php Gdn::Controller()->FireEvent('AfterCategoryTitle'); ?>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.