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.

Where is the View for the category index located?

ericcarlericcarl New
edited October 2011 in Vanilla 2.0 - 2.8
I'm attempting to add some HTML to the top of my category index page. That would be the page you see when viewing a list of discussions that belong to a category (like what you see when you click the "Questions" category link on the right of this forum).

The body tag has a class of "vanilla_categories_index" so I searched for that text in all of the Vanilla files and it doesn't show up anywhere. I've managed to find the index views of other sections (such as categories/all.php and discussion/index.php) but this View seems to be incredibly elusive. I'm getting the feeling this page is cobbled together from multiple files and conditions and might not be as easy as I thought to add some simple HTML to.

Would love some help with this, thanks!


  • Options
    This might help. I couldnt work it out either mate!
  • Options
    jspautschjspautsch Themester ✭✭✭
    edited October 2011
    Try checking out the Index function in the Categories controller, under /applications/vanilla/controllers/class.categoriescontroller.php, it might give you some ideas. I'll keep looking.
  • Options
    jspautschjspautsch Themester ✭✭✭
    I'm wondering if you could make a custom module using some of the same code as the Categories module, because the Categories module can tell when a specific category is being viewed (to highlight that category name), which is exactly what you need to do. Here are its associated files:


    You would then have to load the module somewhere. I would look at the Tagging plugin for an example on how to do this, it creates a custom module and loads it in various places.
  • Options
    jspautschjspautsch Themester ✭✭✭
    edited October 2011
    Better idea: If you use a theme with a default.master.tpl, you could add an event right after the body tag, something like this:
    {event name="BeforeContent"}
    And then create an event handler method in your plugin (e.g. Base_BeforeContent_Handler($Sender), may need to use CategoriesController instead of Base). Try some of the following statements to see if you can retrieve the CategoryID being called, I'm still new at this and don't know exactly how this all works:
    $CategoryID = $Sender->CategoryID;
    $CategoryID = GetValue('CategoryID', $Sender->Category);
    $CategoryID = Gdn::Controller()->Data('CategoryID');
    I'm fairly confident that the last one should work at least, it gets set in the Categories controller.

    If that works, then it's just a matter of echoing some html to display what you want.
  • Options
    Eric, not a solution, but you might want to bookmark this topic, if its done, it might solve your issue
  • Options
    Thanks jspautsch. I'm really just a CSS/HTML guy so I'm pretty rusty with all of the event handling business in Vanilla. More stuff to learn! However I did get a response in this thread from Vanilla staff that sounds really similar to what you're suggesting:

    Tried to make it happen but it wasn't working. Hoping I can get some more help out of that thread so I'll keep you posted. Thanks!
Sign In or Register to comment.