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
Support for Vanilla Forums Cloud product

In this Discussion

Follow Us


Displaying category description

TudorTudor
edited July 2010 in Questions
How can I display the categories descriptions in the category list?

And also on the category page?

Comments

  • Nevermind, I figured out myself. :)
  • and how? ;)
  • 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:


    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.
  • 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:


    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.
  • TudorTudor
    edited July 2010
    Oops, sorry for posting twice.
    And remove all the < br / > from the code, they were inserted by the forum here (< code > tag parsing bugs?)
  • good to know. Many many thanks :)
  • Rardor81Rardor81 New
    edited March 2011
    This works great. Is there any way though to get it in the sidebar panel?
  • 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:

    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).
  • LincolnLincoln Community Instigator Vanilla Staff
    Tart it up. Awesome. :D

    Sr Developer at Vanilla Forums [GitHub, Twitter]

  • It's what we used to say in the UK years before people "pimped" their wagon.
  • would have been great. but the code has changed. helper_functions.php is no longer what it used to be :-(

  • PamelaPamela ✭✭

    happy2b said: 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

  • @Pamela said: happy2b said: would have been great. but the code has changed. helper_functions.php is no longer what it used to be :-(

    yea trying to do that in the latest 2.1 version.... codes are not hte same

Sign In or Register to comment.