Mix of Tags and Categories functionality – not sure how to proceed!
Hi,
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?
Comments
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?
There was an error rendering this rich post.
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.
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: http://www.recreat.io/ (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
You shouldn't modify any file at all Instead you would have to create your own theme. Create following files:
/themes/YourThemeName/about.php
/themes/YourThemeName/views/categories/all.php
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 threeabout.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!
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 http://www.recreat.io/categories Maybe that will already be okay for your first question: showing only first level categories
Take a look at R_J's comment http://vanillaforums.org/discussion/comment/212560/#Comment_212560 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
There was an error rendering this rich post.
I'll try it out and let you all know how it goes. Thanks for the replies
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.
@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.
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.
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.
@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.
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: https://github.com/R-J/AddWPInfo
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: http://vanillaforums.org/discussion/15001/proposed-cascading-categories-first-draft-code-feadback-requested which might do something close to what I need? I'll try it out...