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.

add icons to category

jackmaessenjackmaessen ✭✭✭
edited December 2013 in Vanilla 2.0 - 2.8

Hello, I am looking for a plugin what can add small icons before the category title. It is for a website forum and I would like to use for the different discussion titles different icons just before the title starts.
See the image what I mean:

Best Answers

«1

Answers

  • Welcome to the community!

    What version number of Vanilla are you running?

    So you want something like IndexPhotos, but show a category image/icon rather than the authors photo?

    2.1b2 has this built in, IIRC.

    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.

  • I don't know what version of vanilla you have, since you didn't mention it. alsways a good idea to mention the version of vanilla you are using when asking a question.

    you could look at indexphotos plugin and modify.
    float the image in css.

    get either the categoryid or category name out of the $Args
    
    in the   public function DiscussionsController_BeforeDiscussionContent_Handler($Sender,$Args) {
    
    // pseudocode
    get either the categoryid or category name out of the $Args
    map the  name to an image in your plugin.
    display it
    

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

  • I think he wants an icon per type of category to distinguish them better. If one could pick from a group of icons to add to the title, that would be a great plugin for sure !

    I tried adding the tinymce to the title input box by changing the input to textarea and it seems to work but need to hook the html formatting to that as well to be able to turn it into an editor for titles.

    So a plugin which turns the Title Input Box into an html editor is the key in my meek mind anyway...

  • I am running 2.0.18.9.
    No in the discussion title should the icon be shown. When clicking the topic open, then the author photo is shown.
    see snapshot:

  • CrystalBall Badge is that a plugin? I can not find him when typing it in browse addons...

  • jackmaessenjackmaessen ✭✭✭
    edited December 2013

    oh sorry...I do understand: so IndexPhotos Plugin should do the job.... Oke , I will try it. thank you for response...

  • peregrineperegrine MVP
    edited December 2013

    create a folder and give your images for each categories names.

       IndexCategories/design/indexcategories.css
    

    (you can copy the css and rename it from Indexphotos.css in desingn folder of Indexphotos plugin)


    create your images to match respective name of category(lowercase) or category id (this may be easier if you have (categories with two names).

        IndexCategories/design/images/
        general.png
        php.png
        js.png
    
        etc.
    
        or you could give them names by categoryid
    
        1.png
        2.png
        etc.
    

    cut an paste code below to IndexCategories/default.php

        <?php if (!defined('APPLICATION')) exit();
    
        $PluginInfo['IndexCategories'] = array(
           'Name' => 'IndexCategories',
           'Description' => "Adds a categoryicon to discussions list. clone - Based partially on Indexphotos plugin",
           'Author' => "Peregrine",
        );
    
        class IndexCategoriesPlugin extends Gdn_Plugin {
           /**
            * Extra style sheet if you want it.
            */
           public function DiscussionsController_Render_Before($Sender) {
              $Sender->AddCssFile($this->GetResource('design/indexcategories.css', FALSE, FALSE));
           }
    
    
           public function DiscussionsController_BeforeDiscussionContent_Handler($Sender,$Args) {
             $DiscArgs = ($Args['Discussion']);
              $catbase = strtolower(getvalue("Category",$DiscArgs));
              $catid = getvalue("CategoryID",$DiscArgs);
    
       // base image on Category name 
       // comment line below if images are based on categoryid
        $Image = Img("plugins/IndexCategories/design/images/" . $catbase . ".png", array('class' => "ProfilePhotoSmall")); 
    
     //   base image on categoryID 
      // uncomment line below if images are based on categoryid
     //    $Image = Img("plugins/IndexCategories/design/images/" . $catid . ".png", array('class' => "ProfilePhotoSmall")); 
    
        echo $Image;
           }
    
        }
    

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

  • peregrineperegrine MVP
    edited December 2013

    Well V, at least you, underdog, hgtonight, and underdog,click reactions. thx.

    I think all 3 of us get the Crystal Ball Badge for guessing and mentioning Indexphotos.

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

  • jackmaessenjackmaessen ✭✭✭
    edited December 2013

    well, I tried the IndexPhoto but that is not what gives me the right result. Because, just at the beginning of the tilte, the gravatars (indexphotos) are shown. But they should only be shown when the discussion is clicked open. I want different icons for the discussion title. . So each category has its own icon, en when making a new discussion, the icon of that category what is choosen should appear left to the discussion title. But I see that peregrine has already answered, and I am going to try his solution now...thanks

  • Oke, I have created this:
    In the plugin folder I have made a folder named "IndexCategories".
    This folder contains the file "default.php" and a folder named "design".
    The folder design contains "indexcategories.css" and a folder named "images", in which all the .png files.
    When I now go to my dashboard and click on plugins, I can not find the IndexCategories.

  • jackmaessenjackmaessen ✭✭✭
    edited December 2013

    Well, I have found the plugin with no information about it. But when I press "enable", it says: this add-on could not be enabled because there is a fatal error. so there must be something wrong with the code of default.php

  • See PM

    There was an error rendering this rich post.

  • peregrineperegrine MVP
    edited December 2013

    @jackmaessen

    so there must be something wrong with the code of default.php

    or more likely what you did when you cut and pasted it. since the code has no syntax errors.

    you could also add a version number below the Description

        'Description' => "Adds a categoryicon to discussions list. clone - Based partially on Indexphotos plugin",
         'Version' => '1.0',
    

    and read these if you desire they may help (I guarantee they will give you insights. (don't feel abused or insulted or patronized because these links are provided) , it is for your benefit and ours.

    http://vanillaforums.org/discussion/23130/forum-post-ettikett-etiquette

    http://vanillaforums.org/discussion/17954/food-for-thought-forum-etiquette

    http://vanillaforums.org/discussion/25115/how-to-how-can-a-new-user-better-help-the-community-when-asking-a-question

    http://vanillaforums.org/discussion/23483/advice-for-all-those-just-starting-out-with-vanilla

    http://vanillaforums.org/discussion/20231/how-to-become-somewhat-adept-at-modifying-vanilla-to-meet-your-needs-for-free

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

  • well, I put the version number below the Description, but I can still not enable the plugin. It says: "The plugin folder was not properly defined". I checked all the names of typing mistakes but they are all correct. I also can not see the description near the plugin

  • peregrineperegrine MVP
    edited December 2013

    jackmaessen

    just delete then IndexCategories folder from your file system (what you have already done) because I believe you are doing it improperly.

    then read the links above on etiquette, etc.

    then after you have read the links. upload the file.

    this was meant to help you for a one-off request for free. since it probably exists as in 2.1b2 as hgtonight alluded to. if you want further help from me - send a donation, you can laearn how by reading my profile. And I'll work with you via pm and look at your web-site.

    you can also take part in things that don't concern your immediate question... that might help the community besides yourself.

    e.g.

    http://vanillaforums.org/discussion/25578/nominations-for-best-plugin-created-this-year

    http://vanillaforums.org/discussion/24785/poll-which-registration-method-and-plugins-do-you-use-to-deter-spammers-and-their-efficacy

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

  • jackmaessenjackmaessen ✭✭✭
    edited December 2013

    well Peregrine, I did delete the previous IndexCategories, refreshed the website, unzipped your zip file and replaced the IndexCategories folder again in the plugins folder. Now I could see the description of it. I tried to enable it and the same message: "The plugin folder was not properly defined."
    Anyway, thank you very much for your help but I got stuck on this and I do not know how to fix this problem.

    **
    Update:** IT WORKS!!
    The problem was I opened the website with a different browser and I tried to enable the plugin, and that worked. (Opera). But this is really strange that Chrome could not enable it and Opera could.

  • jackmaessenjackmaessen ✭✭✭
    edited December 2013

    Thanks very much Peregrine. You really did help me with this. I am very glad now this works. Just a little bit configuring the CSS but you can already see it in action here: http://www.webprofis.nl

Sign In or Register to comment.