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 icons on the main page

AgustinAgustin New
edited April 2011 in Vanilla 2.0 - 2.8
Hello! I like to do something like this

Is there any way to do?

sorry for my english image
Tagged:

Comments

  • aeryaery Gtricks Forum in 2.2 :) ✭✭✭
    Yes, such functionality will be really useful.

    Icons for categories like in PHPBB3

    There was an error rendering this rich post.

  • neeeed

  • peregrineperegrine MVP
    edited October 2014

    create icons for each category.

    then you could add a rule for each category name

    span.MItem.Category-talking {
    background-image:  url("new.png") !important;
    background-repeat: no-repeat;
    left: -100px;
    background-size: 25px 25px;'
    position: relative;
    float:left;
    padding: 5px;
    }
    

    put the icons in the design folder of your theme

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • hgtonighthgtonight ∞ · New Moderator

    You want discussions to show an icon based on their category?

    Add the icon via the edit category photo option. Then hook into the discussion list and spit it out.

    public function DiscussionsController_BeforeDiscussionContent_Handler($Sender) {
        $Category = CategoryModel::Categories($Sender->EventArguments['Discussion']->CategoryID);
        $PhotoUrl = GetValue('PhotoUrl', $Category);
    
        if ($PhotoUrl) {
          $Link = Anchor(
                  '<img src="' . $PhotoUrl . '" alt="' . htmlspecialchars(GetValue('Name', $Category)) . '" />', CategoryUrl($Category, '', '//'), 'CategoryPhoto');
        } else {
          $Link = Anchor(
                  ' ', CategoryUrl($Category, '', '//'), 'CategoryPhoto Hidden');
        }
        echo $Link;
    }
    

    Tested in 2.1.3. Style to suit. I stole the following CSS from the IndexPhotos plugin:

    .CategoryPhoto {
       float: left;
    }
    
    .CategoryPhoto img {
       height: 40px;
       width: 40px;
    }
    
    .Discussion.ItemContent {
       padding-left: 48px;
    }
    

    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.

  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    @hgtonight said:
    You want discussions to show an icon based on their category?

    Yes, peregrine already made that plugin ... but I am not sure he uploaded it, maybe it was a one off...

  • vrijvlindervrijvlinder Papillon-Sauvage MVP
    edited October 2014

    He should upload it coz it's very cool !!

  • peregrineperegrine MVP
    edited October 2014

    Yes, peregrine already made that plugin ... but I am not sure he uploaded it, maybe it was a one off...

    mine was for 2.0.18.x when the 2.1.x didn't have a photo option in dashboard.

    and @hgtonight is better for 2.1 since it has a clickable category icon.

    dueling discussions!

    http://vanillaforums.org/discussion/28227/caticon

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • @hgtonight said:
    Then hook into the discussion list and spit it out.

    I've been trying this, but I'm unsure what file and where in it I should place this code. My attempts so far have only ended up with errors.

  • @omfgblondie said:
    I've been trying this, but I'm unsure what file and where in it I should place this code. My attempts so far have only ended up with errors.

    just create a plugin. or add it to the themehooks of your theme. test on bittersweet till you get it working.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • @peregrine said:
    just create a plugin. or add it to the themehooks of your theme. test on bittersweet till you get it working.

    Thank you! I got it working on bittersweet!

Sign In or Register to comment.