Please upgrade here. These earlier versions are no longer being updated and have security issues.

Change where the categories are listed to the top of main content on the page

2»

Comments

  • @vrijvlinder said:
    I gave you the wrong location for this categories module, I tested this theory and it worked. The simplest is to change the target to Content and they show right before the content

    forum/applications/vanilla/modules/class.categoriesmodule.php

    change this in that file to this

    public function AssetTarget() {
          return 'Content';
       }
    

    You will need to sort the modules if you want the warning messages that can go there to be at the top.

    Thanks, I want to try and stay away from plugins at the moment. I've got it working with

    public function AssetTarget() {
    return 'listCategories';
    }

    in forum/applications/vanilla/modules/class.categoriesmodule.php

    and then

    {asset name="listCategories"} {asset name="Content"}

    in /applications/dashboard/views/default.master.tpl

    Seems to do the trick :)

  • hgtonighthgtonight ∞ · New Moderator
    edited May 2014

    Wrapping your modifications in a theme or plugin right now will save you a lot of headache later. Modifying core files prevents you from updating without breaking things.

    Plugin Method

    1. Create a plugin
    2. Override the Categories module to return 'Content' for AssetTarget()
    3. Change the module sort order via config

    Theme Method

    1. Create theme
    2. Override the default.master.tpl file and insert {module name="CategoriesModule"} where you want the categories to show up
    3. Hide the original module via CSS.

    Similar amount of work. I prefer the plugin route myself.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • @hgtonight said:
    Wrapping your modifications in a theme or plugin right now will save you a lot of headache later. Modifying core files prevents you from updating without breaking things.

    Plugin Method

    1. Create a plugin
    2. Override the Categories module to return 'Content' for AssetTarget()
    3. Change the module sort order via config

    Theme Method

    1. Create theme
    2. Override the default.master.tpl file and insert {module name="CategoriesModule"} where you want the categories to show up
    3. Hide the original module via CSS.

    Similar amount of work. I prefer the plugin route myself.

    Is it not possible to have the files I modified in side of my own theme folder?

    If not, I guess I'll look at going the plugin route, is there any documentation on making a plugin as described?

    Thanks

  • hgtonighthgtonight ∞ · New Moderator

    If you place your current modifications in a theme, you are doing fine.

    It just seems like a complicated approach when you could just change the asset target to content and the sort order via a config.

    I can post some specific examples/steps when I wake up more.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

    R_J
  • Ideally I want to keep it separate to other themes etc so when it comes to uploading or editing later I can just change files in my theme folder.

    Yes please, if you can upload any examples you think will help. It's the 1st that time I'm working with Vanilla so the more the merrier :)

  • hgtonighthgtonight ∞ · New Moderator

    Alright, what you need to do is add the categories module to the sort order of the content asset for the Vanilla application. Put $Configuration['Modules']['Vanilla']['Content'] = array('MessageModule', 'MeModule', 'UserBoxModule', 'NewDiscussionModule', 'ProfileOptionsModule', 'Notices', 'NewConversationModule', 'NewDiscussionModule', 'DiscussionFilterModule', 'CategoryModeratorsModule', 'CategoriesModule', 'Content', 'Ads'); in your /conf/config.php file. You will notice that this is just an array of module names. The order of the items determines the display order of each of those modules. I added 'CategoriesModule' right before 'Content' which is not to be confused with the asset but a special content module that holds the rendered view of the controller.

    Then you need to copy the modules folder from the attached zip in your custom theme. You will have to disable/re-enable the theme to refresh the cache, IIRC. All that is in this folder is a copy of the class.categoriesmodule.php with the AssetTarget() method returning 'Content' instead of 'Panel'.

    Now, whenever an application wants to add the categories module to a controller, the autoloader sees this modified version and will load it instead of the original core. It will put itself in the Content asset and your sorting config puts it above the pages content.

    If you don't want to make it theme dependent, the attached zip is actually a plugin that can be used instead. You will still have to copy to configuration over manually for some technical reasons.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

Sign In or Register to comment.