HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

How to apply Spoilers in the category description

rbrahmsonrbrahmson "You may say I'm a dreamer / But I'm not the only one"NY ✭✭✭

I looked around and couldn't find anywhere a related answer so perhaps someone has one. Some of our categories descriptions are long and take valuable space in the discussion list. It would be nice if Spoilers would work on the categories descriptions as well. I see the plugin has the following code:

     public function DiscussionController_Render_Before(&$Sender) {
          $this->PrepareController($Sender);
       }

which I hoped would do the trick,but I'm not yet at the level of understanding how this works...

Comments

  • peregrineperegrine MVP
    edited July 2015

    At first glance, you would be better off creating a new plugin. The events are totally different

    and there is no changing of format body, since it is not a post.

    you would need to add a button that hides and displays via jquery. You would need to study some jquery tutorials on hiding and displaying via a button. then figure out how you are going to add that button to the text of the category description.

    I don't have the time or interest regarding this plugin to help you further though

    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

    This seems like a fairly simple JS plugin.

    Here is a jQuery plugin that does what I think you are looking to do: https://github.com/vaakash/jquery-collapser

    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.

  • rbrahmsonrbrahmson "You may say I'm a dreamer / But I'm not the only one" NY ✭✭✭

    @hgtonight - this is really cool. I am reading the documentation and had to stop to thank you for this. I will test it with Pockets and then decide how to apply it. Thanks again!

  • rbrahmsonrbrahmson "You may say I'm a dreamer / But I'm not the only one" NY ✭✭✭

    I'm testing the jQuery approach suggested by @hgtonight and it requires that the text to be managed by it be in a paragraph with an html tag. However when trying to enter html in the category description I suspect that Vanilla removes these tags.

    I haven't given up on this approach, I like the ability to have another way outside of the standard plugins to modify the forum (same reason I like Pockets).

    I could try a mixed approach - plugin that adds the html tags and the jQuery plugin. Problem is to discover something/event that can change the description of categories in discussion list. As @peregrine wrote above, I'll need to find a way to place something in the description, and I haven't found it yet..

  • BleistivtBleistivt Moderator

    Vanilla 2.2 allows HTML in category descriptions.

    https://github.com/koenweyn/vanilla/commit/6157f8fd01d2d9fdcbbf7e3de6b159f70a9c3279

    To make things a lot simpler, you could just apply this patch until 2.2 is out of beta.

  • rbrahmsonrbrahmson "You may say I'm a dreamer / But I'm not the only one" NY ✭✭✭

    Thanks @Bleistivt ! That's great.

  • peregrineperegrine MVP
    edited July 2015

    @Bleistivt said:
    Vanilla 2.2 allows HTML in category descriptions.

    @rbrahmson.

    even if it didn't , you could easily add html tags with jquery. look at append functions. if you go through jquery tutorials, and build your own, you will learn alot more than reusing someone else's function

    the key to learning is trying to build things and go through jquery tutorials. you don't need to do it in vanilla first, create a little web page outside vanilla, and do it. they probably have jquery and php books in the library near 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.

  • rbrahmsonrbrahmson "You may say I'm a dreamer / But I'm not the only one" NY ✭✭✭
    edited July 2015

    @peregrine - will do. Just FYI I verified that V 2.1.11 does strip html tags - I added "This is a test category. << p class="myElement">>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.<<//p>>" to the category description and then when displaying the page I right-clicked and selected "view page source" which showed that the 'class="myElement"' was not there. The "typos" in the tag syntax above were added because it appears that this forum discussion also strips html...

    I will play with the jquery append class. Thanks for the hint.

  • hgtonighthgtonight ∞ · New Moderator

    @rbrahmson You should be able to use a different selector. Like .Categories .PageDescription.

    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.

  • rbrahmsonrbrahmson "You may say I'm a dreamer / But I'm not the only one" NY ✭✭✭

    Thanks @hgtonight, looks like I'll need it for both ".CategoryDescription" and ".P.PageDescription" (categories and subcategories).

  • rbrahmsonrbrahmson "You may say I'm a dreamer / But I'm not the only one" NY ✭✭✭
    edited July 2015

    @Bleistivt said:
    Vanilla 2.2 allows HTML in category descriptions.
    https://github.com/koenweyn/vanilla/commit/6157f8fd01d2d9fdcbbf7e3de6b159f70a9c3279

    To make things a lot simpler, you could just apply this patch until 2.2 is out of beta.

    Thanks @Bleistivt, I did not ignore your feedback, just waited until I tested it. So I went to the source of my installed 2.1.11 version and indeed the code is there - I don't have to wait for V 2.2. I went further and added some simple HTML tags (break, paragraph, a link) and they were not stripped and worked as expected. But then I added a class="whatever" to the paragraph tag and it was stripped. I therefore expect similar behavior in V2.2.

    I presume this is done as a protection mechanism.

    Just FYI. As suggested above I'll try other ways with Jquery.

Sign In or Register to comment.