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.
Options

Showing description under Category name

422422 Developer MVP
edited October 2011 in Vanilla 2.0 - 2.8
We have category Blog.
We have description for it, eg: Check out our blog.

When we click on the blog category, we get :

↳ Blog

But no description underneath it. Any idea why ?

There was an error rendering this rich post.

Answers

  • Options
    ToddTodd Chief Product Officer Vanilla Staff
    The category description is meant for the categories/all page. We put in below the category title with the following code in our theme hooks:
    public function CategoriesController_AfterBreadcrumbs_Handler($Sender, $Args) {
    $Description = $Sender->Data('Category.Description');
    if ($Description) {
    echo ''.$Description.'';
    }
    }
  • Options
    422422 Developer MVP
    Thanks for that, but not fully comprehending your template system, could you be a little more explanatory as to which template would need to be modified.

    I am still getting to grips with Vanilla.

    There was an error rendering this rich post.

  • Options
    ToddTodd Chief Product Officer Vanilla Staff
    Read about theme hooks here.
  • Options
    422422 Developer MVP
    Ok I have done that:
    class [PluginName]ThemeHooks extends Gdn_Plugin { public function CategoriesController_AfterBreadcrumbs_Handler($Sender, $Args) { $Description = $Sender->Data('Category.Description'); if ($Description) { echo ''.$Description.''; } } }
    And named it class.422themehooks.php and uploaded to our plugin folder ?? the above code doesnt seem to have changed anything...

    There was an error rendering this rich post.

  • Options
    sahotataransahotataran Developer, Bay Area - CA ✭✭✭
    i think theme hooks go into your theme folder - the theme you have activated and it wont work in the plugins

    There was an error rendering this rich post.

  • Options
    422422 Developer MVP
    So I need to create a New Plugins folder within mytheme folder ? Then add that code ??

    There was an error rendering this rich post.

  • Options
    I found 1 theme in the addons site that also has themehooks.
    http://vanillaforums.org/addon/527-vanillaforums.org-old-blue
    If it works there, maybe that can give you an example for your theme :-)

    There was an error rendering this rich post.

  • Options
    422422 Developer MVP
    Good onya thanks, I can get the hook to fire , just not todds code, so obviously I m doingsomething wrong. Will check that out, thank you..... And report back

    There was an error rendering this rich post.

  • Options
    class 422ThemeHooks extends Gdn_IPlugin {

    I believe

    grep is your friend.

  • Options
    422422 Developer MVP
    Tried that x00 seemingly, doesn't like numerical class.. Still fiddling tho thnks

    There was an error rendering this rich post.

  • Options
    x00x00 MVP
    edited October 2011
    doh! yes class name must start with an Alphabetical character.

    I would also be more descriptive.

    class CategoryDescriptionThemeHooks extends Gdn_IPlugin

    grep is your friend.

  • Options
    theme hook usually are in a plugin not theme, if you wan them to be in a theme you extend Gdn_IPlugin

    and name the file class.public_[name].php where [name] is the lowecases name of the class. Like class.public_categorydescription.php.

    grep is your friend.

Sign In or Register to comment.