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.

Category logo problem

the logos shows when i check Categories via PanelColumn.

but the logo not showing when i check via level2 forum and level3 forum.

how do i make it shows?

image
image
image
image

Comments

  • KasperKasper Vanilla Staff
    edited August 2013

    You'll have to add the icons either by overriding the appropriate views or by making use of events. The category icons can be output using the CategoryPhoto() function located in the category helper functions. Here's the basic code you'll be needing:

    // Include category helper functions
    include_once $this->FetchViewLocation('helper_functions', 'categories', 'vanilla');
    
    // Write out the category photo
    echo CategoryPhoto($Category);
    

    Kasper Kronborg Isager (kasperisager) | Freelance Developer @Vanilla | Hit me up: Google Mail or Vanilla Mail | Find me on GitHub

  • jeongweejeongwee ✭✭
    edited August 2013

    i wanted to show the logo of the level3 forum categorys at picture 3 .

    after i copyed the views/discussions/index.php to my theme file and added

    echo CategoryPhoto($Category);

    to after line

    include $this->FetchViewLocation('Subtree', 'Categories', 'Vanilla'); 

    it showed a logo ...... but it's a logo of level2 forum , not a logo of level3 forum.

  • edited August 2013

    Here is what you need to get started with outputting the sub-category photo in Vanilla 2.1+.

    1. Create a file called class.THEMENAMEthemehooks.php. Replace THEMENAME with your theme's name in lowercase.

    2. In the file, you would need this and replace the word "THEMENAMEThemeHooks" with your theme's name in camel case:

    <?php if (!defined('APPLICATION')) exit();
    
    class THEMENAMEThemeHooks extends Gdn_Plugin {
       public function CategoriesController_AfterCategoryTitle_Handler($Sender) {
          echo CategoryPhoto($Sender->EventArguments['Category']);
       }
    }
    
    

    This will output the category photo in the subtree view that is displayed when viewing the first level category. You can then add some custom CSS rules in your theme to style the sub-category icons.

    Add Pages to Vanilla with the Basic Pages app

  • edited September 2013

    Also, you would need to check if you are viewing a category and not the categories index since the AfterCategoryTitle event is also fired on the categories index.

    For example:

    <?php if (!defined('APPLICATION')) exit();
    
    class THEMENAMEThemeHooks extends Gdn_Plugin {
       public function CategoriesController_AfterCategoryTitle_Handler($Sender) {
          if($Sender->RequestArgs[0] != '')
             echo CategoryPhoto($Sender->EventArguments['Category']);
       }
    }
    
    

    Add Pages to Vanilla with the Basic Pages app

Sign In or Register to comment.