Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Try Vanilla Forums Cloud product
Please upgrade to 2.3 here. The 2.2 and earlier branches are no longer being updated.

LikeThis Plugin - Show the 'like' on comments in one category only

This discussion is related to the I Like This ( Plugin ) addon.
mystromystro New
edited June 2012 in Vanilla 2.0 - 2.2

I have a category for Feature Requests and have installed the LikeThis plugin.

I want the 'like' to show on discussions/comments in the Feature Requests category only. When viewing the code in firebug, I can't see a separate ID/class for the Feature Requests category page.

Any ideas?

Comments

  • peregrineperegrine MVP
    edited June 2012
    $Object = ($Sender->EventArguments['Discussion']);
    $Sender->Category
    $Object->CategoryUrlCode
    

    @mystro if you have to modify the plugin you could possibly add the above variables and test for a match against the categories you want to use. I haven't looked at the plugin though.

    look at the other category plugins to get an idea if you need to.

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

  • hbfhbf wiki guy? MVP

    @mystro said:
    I have a category for Feature Requests and have installed the LikeThis plugin.

    I want the 'like' to show on discussions/comments in the Feature Requests category only. When viewing the code in firebug, I can't see a separate ID/class for the Feature Requests category page.

    Any ideas?

    @mystro did you solve this?

  • Hi hbf,

    No, I never did solve this! Any advice? :)

  • peregrineperegrine MVP
    edited January 2013

    if you want you could try this:

    it should only show the like button for the category named "Feature Requests" as you requested.

    change in default.php around line 205

        if (!Gdn::Session()->UserID) return;
    
       //add these five lines 
       $Object = ($Sender->EventArguments['Discussion']);
       //  if you wanted you could make this a config statement or array to test multiple categories
       $allowedcat = "Feature Requests";
        if (Gdn_Format::URL($Object->CategoryUrlCode) <> Gdn_Format::URL($allowedcat)) return;
    

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

  • hbfhbf wiki guy? MVP

    @peregrine said:
    if you want you could try this:

    it should only show the like button for the category named "Feature Requests" as you requested.

    change in default.php around line 205

        if (!Gdn::Session()->UserID) return;
      
       //add these five lines 
       $Object = ($Sender->EventArguments['Discussion']);
       //  if you wanted you could make this a config statement or array to test multiple categories
       $allowedcat = "Feature Requests";
        if (Gdn_Format::URL($Object->CategoryUrlCode) <> Gdn_Format::URL($allowedcat)) return;
           
    

    that looks right to me, though I'm not sure you need to URL Format both sides of the comparison.

  • @hbf

    As it stands ($Object->CategoryUrlCode) probably didn't need to be formatted,

    But I figure the extra millisecond was worth it, if something changed in the future with respect to CategoryUrlCode they would still be in the same format with respect to case, spacing, and internationalization.

    Anyone who wants to provide code snippets or modify or improve on things is more than welcome. And I don't mean this as a snipe or an insult to you or anybody else. I just believe code snippets when applicable to directly answering the question (as opposed to random code splatted into a discussion) are quite valuable. At least they are to me, when others post them.

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

  • hbfhbf wiki guy? MVP

    and, here is a dollar's worth:

    if you want to make this a more powerful (and professional) customization, you would add a permission to the discussion permissions model which you could use to set "by role" permission to like a post. you would then to accomplish the single category "likeability" you would set no like permissions on all other discussion categories, then create a new category with unique permissions, then go through your roles and set the Like permission to True.

    I'm not posting code snippets, since that's a fair amount of work. I will do the work for a fee, PM me if you are interested (no it's not going to be $10 or anything close to that).

  • Thanks for taking the time to help with this, very much appreciated! I'll test these out and let you know of the outcome :)

  • peregrineperegrine MVP
    edited January 2013

    @mystro said...

    I'll test these out and let you know of the outcome :)

    no problem. Based on the requisites you established - I know the "code snippet" I presented for you to "cut and paste", does indeed work on vanilla 2.0.18.4.

    I think you mean "this" not "these" as far as a professional category broad based solution, since I only presented one code snippet.

    However, if you are talking about the professional permission based solution, which could allow for a finer tuning based on role and category. - then hbf has the ideal solution for you.

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

Sign In or Register to comment.