HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Pocket link that adapts to category being viewed
Just a quick question about pockets.
Is there a way to generate a link dependent on the category the discussion being viewed is in?
Viewing a thread in the "Widgets" category.
The Pocket link might go to http://mymainsite/help/widgets
"widgets" being appended to the end of the url as above.
I thought it was something really easy I was missing and was embarrassed to ask
But then I came here because I was sure I was overcomplicating things and there must be an easier way.
Take a look at adding a conditional in the blog I linked to.
This might help
You can get the category from the gdn.meta objet. Try
console.log(gdn.meta.eventData.discussion.category.categoryID);in the console. As you will see, the category name is also available, if you prefer that.
@Kaspar Thanks for that. But really looking for something that will work in a pocket for now. But I've bookmarked that as it's really useful and given me a few ideas about other things.
@R_J That actually works really well!! But only when viewing a discussion. Ideally I'd need something that works in the category list as well.
The condition examples in the blog is in/for a pocket
That's a very good hint! You could also use a custom theme and in that theme you should be not only able to use $Category.CategoryID, but also $Discussion.CategoryID
If you want to stick to the js approach, take a look at the body class. It should have body.Categories.Category-thecategoryname
Ah that can go into pockets?
I had a go but all I got was the smarty on the page. I'll look through the documentation rather than lazily having a cut and paste 😁
No, Smarty code isn't recognized inside a pocket, as far as I know. The link explains what you can put into your themes default.master.tpl in order to conditionally show content.
So in order to do so, you would have to create different pockets and then include a Smarty snippet in your theme (please use your own custom theme if you decide to do so) where you want to show the pocket, e.g. at the bottom of the side panel: https://github.com/vanilla/vanilla/blob/master/addons/themes/keystone/views/default.master.tpl#L285