Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Archive

Active Page If page:1?

Started by Muut Archive 12 years ago · 8 replies · 393 views
12 years ago

% set current_page = (p.active or p.activeChild) ? 'active' : '' %} does not set the current_page to active if the page is of the form blog/page:1

The Antimatter theme has this problem, too, but not the main Grav blog.

Does Grav have a test for that case, or should I construct something myself?

12 years ago

i can confirm this is a bug if the page with pagination is the home page. I will look into it.

12 years ago

Ok, there is a simple fix for this. Edit your /user/config/site.yaml and add this:

YAML
blog:
  route: '' 

As there is no blog.route set, it's default to /blog as provided in the system/config/site.yaml and that is why it's adding the /blog in the URL and losing the active state in the menu.

12 years ago

I was hoping this would also fix the problem where blog posts are not seen as children to the main blog page, so the blog menu items doesn't get the active class. My blog post URLs look like this: /blog/what-if-photos-is-great.

Is the /blog/ part still to blame?

Yep, I cleared my caches. :)

12 years ago

Yah, those base_url value (current version of Antimatter) is built with site.blog.route. And that is defaulting to /blog in the system/config/site.yaml.

My fix was to override and set this value in your /user/config/site.yaml. I tested this and it worked.

I've actually changed Anitmatter for the next release so that this value will no longer be used. It will set base_url to page.url in blog.html.twig and set it to page.parent.url in item.html.twig. This will ensure you won't need that site.blog.route to be provided going forward.

So to summarize, my fix does work, you may of just changed the wrong file, or changed it incorrectly. By changing the config file, it should automatically update the cache.

12 years ago

Actually spoke to soon.. Works fine on homepage, but not on an 'item' page. Will look at that again.

12 years ago

Ok proper fix will be in 0.9.5 release (tonight?) if i can get my house chores done! :)

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1281 9 years ago
Archive · by Muut Archive, 9 years ago
2 888 9 years ago
Archive · by Muut Archive, 9 years ago
2 4018 9 years ago
Archive · by Muut Archive, 9 years ago
1 2894 9 years ago
Archive · by Muut Archive, 9 years ago
3 1077 9 years ago