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.

Mix of Tags and Categories functionality – not sure how to proceed!

edited July 2014 in Vanilla 2.0 - 2.8


I'm almost done setting up my new forum (Vanilla 2.1), but there's one thing left which I haven't found how to do. I'll use an example, to explain.
Let's say I have this category hierarchy:

  • Fruits
    • Kiwi
    • Orange
  • Vegetables
    • Carrot
    • Peas
  • Meat

What I wish is for users to only be able to pick a category from the lowest levels when they create a discussion – so, in this case, it'd be Kiwi, Orange, Carrot, Peas and Meat. This is easily achievable by making the root categories display as headings (I could place Meat into a parent category).

But then, I'd like users to only be able to browse the _top _ categories, so Fruits, Vegetables and Meat... selecting one of those would display all of the posts from the sub-categories, with the ability to hide one of them. So, in the Fruits page, I would see discussions marked as belonging to either Kiwi or Orange, and I could filter them to display only Oranges. Basically, this behaviour is closer to how tags work, but I don't want user to be able to set tags; I want them to pick from the exiting options. (The other reason why tags wouldn't work is that users would be able to use the 'Peas' tag for a discussion in the Fruits category.)

The homepage would display only the top categories (Fruits, Vegetables, Meat), allowing the user to pick the page to go to. Ideally you'd also have the most recent discussions displayed under each one, but that's not absolutely necessary.

I haven't been able to come up with a way to do this, but maybe there is one. How would I be able to achieve to what I want, or something close?



  • What you would like to do is clear, just show on which page you want to make that view, because I think you make a new view

    Which theme are you using? If custom, with which theme did you start?

  • peregrineperegrine MVP
    edited July 2014

    In your example I wonder if it would be easier to have two categories.

    then have a tag dropdown that is required and only has the tags available for that specific category when starting a discussion. so user pick category Fruit, and chooses from tags apple, orange, banana, pomegranate and then posts.

    or chooses vegetable category then picks from available dropdown tags peas, carrots, eggplant, squash

    rathenr then gyrating categories and views for less than optimal display, just use tags but modify tagging plugin that only allows tags from a specified dropdownlist based on category.

    how you decide to do it also might depend on your version of vanilla.

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

  • R_JR_J Ex-Fanboy Munich Admin

    I haven't been able to come up with a way to do this, but maybe there is one. How would I be able to achieve to what I want, or something close?

    There is now way to achieve that just with configuration. You would have to come up with custom views. Have you tried creating a view by yourself, too?

  • @UnderDog‌, here is the website where I'd want to do this: (sorry I didn't link it before, I had to do a bit of cleaning.)

    As you can see, I'm still using the default them, and plan on modifying the CSS once I'm done implementing all the functionality I want.

    @peregrine‌, yeah, it's entirely possible that it'd be easier to modify the Tagging plugin. I just don't have the slightest idea how to proceed; I'll have a look, I guess...

    @R_J‌, no I haven't tried creating a view... I can have a look as well, but in this case I don't even know which file(s) I should modify :x

  • R_JR_J Ex-Fanboy Munich Admin

    You shouldn't modify any file at all ;) Instead you would have to create your own theme. Create following files:

    Take a look at other themes about.php and copy the structure of them. You'll see what you have to do if you look at two or three about.php files.
    Copy the contents of /applications/vanilla/views/categories/all.php to your newly created all.php file. Now you can start modifying that file so that it only shows first level categories.

    If you are finished with that, you will have a better understanding of what is needed to modify/create other views to behave like you want to.

    Come back at any time with your questions! :)

  • R_JR_J Ex-Fanboy Munich Admin

    Oh, maybe that config setting will be helpful:

    $Configuration['Vanilla']['Categories']['MaxDisplayDepth'] = 2;

    (add that line to your /conf/config.php file)

    Try that and look at Maybe that will already be okay for your first question: showing only first level categories

  • Take a look at R_J's comment that is the first thing all the regular users would respond when you say you want to change something in your theme

    The /categories look nice, so let's see if you can follow R_J's advice once you're ready to modify it to your taste

  • I'll try it out and let you all know how it goes. Thanks for the replies :)

  • peregrineperegrine MVP
    edited July 2014

    I was trying out this idea, just for an experiment.

    If a person posts in a certain category it picks up the proper selection values. If they change the category, however, I can validate and force a repost, but I can't think of a way without js to redo the tag options.

    I'm not sure how to effect a change without storing all the options in js.

    If anyone has any ideas to get the select options to change upon category change or at least repost the correct tag values on a forced re-post on validation event.

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

  • AccentAccent
    edited July 2014

    @peregrine, maybe have two drop-downs, one containing the fruit tags and one with the vegetable tags, and hide/show them depending on which category is selected? Then upon posting you check which one is currently shown and select that tag for the discussion... I don't know if that helps at all.

    edit: for my needs, I would be totally okay with just removing the drop-down entirely, haha. If users want to post in a different category they'd have to actually browse into that category and start a new discussion from there, and then that category would be selected and the proper tags would be selectable.


    Anyway, I've been looking at the various .php files in views/categories, and to be honest I'm a bit lost... I don't know anything about php. I kiiinda learnt JS recently by trying to modify some scripts without knowing anything about it beforehand either, so maybe I'll manage to reproduce that scenario, but it'll take time...

    I also thought of a way to implement what I need, though: I think the categories should be given two options, Postable and InParent.

    • When Postable is true, you guessed it, you can select that category in the drop-down menu when creating a discussion (you can't if it's false).
    • When InParent is true, all of the posts from that category are also displayed in its parent category. That way you can still click on it in the category list in the sidebar, if you only want to see it and not other categories under the same parent.

    Then I'd set Postable to false for Fruit and Vegetable, and InParent to true for Oranges, Kiwi, Carrot and Peas. Not setting anything special for Meat means it acts like a normal category.

    I don't know how easy to do that'd be... nor if it'd work at all. It's not 100% perfect, but it should get the job done, and I can't think of anything that wouldn't be covered.

  • peregrineperegrine MVP
    edited July 2014

    for my needs, I would be totally okay with just removing the drop-down entirely,

    Then you couldn't edit categories. (inablilty to edit discussion to move in to correct category if mis-posted.
    and it would be confusing to users.

    still, would be interesting to come up with a variety of solutions as you say.

    Categories only.

    or Categories with selectable tags (if there was a decent way to do it effectively).

    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 July 2014

    @accent, I found a way to do something like this to select tags from categories. haven't coded any saving or validating but it places correct items for the selected category in dropdown. And updates list on category selection.

    the category name would need to be in the tag selection drop down box - but it filters correctly.

    still needs a bunch more work.

    I sent you a PM to reflect upon, if you want me to pursue this way.

    Otherwise, you can go the R_J route, which may meet your needs as well.

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

  • R_JR_J Ex-Fanboy Munich Admin

    If you're not familiar with php at all, you'll have a problem modifying the needed views. But in the long run, to really give your side a unique look, you will have to understand at least some php. I believe Vanilla is a good start for learners (it has indeed helped me a lot).

    If you are using tags, you might be interested in that (very rigid) plugin:

    It has only one purpose and isn't made to be configurable. But nevertheless it could be changed. It adds a dropdown to new discussions in special categories, where user can choose between 3 different tags. If you mix up peregrines code and mine, you'll be one big step closer.

  • @peregrine‌, The inability to post a discussion in a category other than the one currently being seen is actually the behaviour of most forums :P so I 'don't think users would be too confused by it.

    Anyway, your solution with the tags that include the name of the category totally works for me. :)

    @R_J, thanks, I'll have a look!

  • By the way I just found this: which might do something close to what I need? I'll try it out...

Sign In or Register to comment.