Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Page not active in the navbar if output is not the default. #110

Closed
andreburgaud opened this issue Jan 29, 2014 · 1 comment
Closed

Page not active in the navbar if output is not the default. #110

andreburgaud opened this issue Jan 29, 2014 · 1 comment

Comments

@andreburgaud
Copy link

When pages are configured to show up in the navigation bar with a non default SAVE_PAGE_AS, selecting a page in the navbar does not set the corresponding page title style as active on the menu.

Configuration Example:

...
DISPLAY_PAGES_ON_MENU = True
PAGE_URL = '{slug}'
PAGE_SAVE_AS = '{slug}/index.html'
...

The resulting code for mypage, located in mypage/index.html would be something like:

<li><a href="http://example.com/mypage">My Page</a></li>

But should be:

<li class="active"><a href="http://example.com/mypage">My Page</a></li>

In base.html the comparison is made between output_file and page_url. In the example above, output_file is index.html and page_url is mypage.

Here is a possible fix, mostly taken from the simple template in pelican:

--- a/templates/base.html
+++ b/templates/base.html
@@ -60,8 +60,8 @@
                         <ul class="nav pull-right top-menu">
                             <li {% if page_name == 'index' %} class="active"{% endif %}><a href="{{ SITEURL }}">Home</a></li>
                             {% if DISPLAY_PAGES_ON_MENU %}
-                            {% for page in pages %}
-                            <li {% if output_file == page.url %} class="active"{% endif %}><a href="{{ SITEURL }}/{{ page.url }}">{{ page.title }}</a></li>
+                            {% for p in pages %}
+                            <li {% if p == page %} class="active"{% endif %}><a href="{{ SITEURL }}/{{ p.url }}">{{ p.title }}</a></li>
                             {% endfor %}
                             {% endif %}
                             <li {% if page_name == 'categories' %} class="active"{% endif %}><a href="{{ SITEURL }}/categories.html">Categories</a></li>

I tested it successfully with the default configuration for the page output and with the configuration mentioned above.

@talha131
Copy link
Member

talha131 commented Feb 7, 2014

@andreburgaud thanks a lot for fixing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants