Can’t believe we missed the link helper article. However, I noticed the #link sets the class to anchor tag. Is it possible to set to for a li instead, @DavidDarnes ?
It seems to me the link you shared talks about defining a specific slug for for. In the example you shared it says /about/. However, is it possible to have the value for for be set as dynamic instead of static @DavidDarnes?
Hi @DavidDarnes, however, the active element is working in local machine, but seems to be not working in a staging server, the code is same, is there any specifications needed ?
I am adding the code snippet for your reference, we are using Casper theme
{{#if primary_tag}}
{{#get “posts” filter=“tags:{{primary_tag.slug}}” limit=“10” as |related_posts|}}
What’s puzzling is, the code seems to work fine on local. But after pushing it to digitalocean as a .zip file, the activeClass="active" doesn’t seem to be firing.
Oh I see - so in Dave’s example he used (url) to indicate a dynamic value, on the docs you’ll see you need to pass in the value you want to match: Ghost Handlebars Theme Helpers: link_class
The helper asks, does the current window.location match /about/ ? If yes: add the active class. If no, do nothing.
If you want to dynamically pass in the {{url}} from the foreach loop, I think the way to do that is without curly braces (I have not tested this) like:
Removing the curly brackets did the trick. For future reference, we used url instead of slug. Although I am curious how it worked in the local? Thanks for the prompt replies, @John.