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.

Support

Anchors with special character causes error in singlePageNav.js

Started by Anders 8 years ago · 1 replies · 588 views
8 years ago

I'm customizing my first creation with Grav using One Page skeleton (quark theme).

I'm stuck on JS errors thrown when using navigation/topmenu that links anchors on my "one-page" landing page. The error thrown in singlepagenav.min.js is a Error: Syntax error, unrecognized expression: due to the modular page using special characters Å Ä or Ö. The smooth scroll to that anchor is also broken.

What should I do, I've tried to change menu name, title of the modular page and so on without success. Is there a possibility to get Grav to output an encoded anchor without spec.characters or do I have to change the JS (I've got minimal knowledge about this sort of JS).

js_error|446x165

The link is formatted like this: "http://localhost:port/webroot/#våra_tjänster"

last edited 10/07/18 by Anders
8 years ago

I found a super simple solution.

Given you are using the Quark theme and "one-page" skeleton you can make these changes:

In modular.html.twig on line 38 i changed the creation of the link:

From
<li><a class="{{ current_module }}" href="#{{ _self.pageLinkName(module.menu) }}">{{ module.menu }}</a></li>

To
<li><a class="{{ current_module }}" href="#{{ _self.pageLinkName(module.title) }}">{{ module.menu }}</a></li>

Furthermore In modular.html.twig on line 51 and 58 i changed the creation of the anchor in the html:

From
<div id="{{ _self.pageLinkName(module.menu) }}"></div>

To
<div id="{{ _self.pageLinkName(module.title) }}"></div>

This giving me the option to set the title of the modular page without special characters while having a "Menu" override option with my special characters that is presented in the navigation.

👍 1
last edited 10/08/18 by Anders

Suggested topics

Topic Participants Replies Views Activity
Support · by Thomas, 1 week ago
3 90 1 hour ago
Support · by Anna, 3 days ago
2 92 22 hours ago
Support · by Justin Young, 23 hours ago
1 40 23 hours ago
Support · by Duc , 1 week ago
2 98 6 days ago
Support · by Colin Hume, 1 week ago
2 90 6 days ago