Updated from 5.5.2.1 to 5.6.1 - self-hard-coded navigation not working as intended anymore.
Permalink
Hi guys,
I've just installed a fresh copy of concrete5 (5.6.1) on a new host (My old host had version 5.5.2.1) and I'm having difficulties with getting the (custom) theme I was working on to work like it was on this new install.
The problem I'm having lies in the navigation.php element I have on my theme, which is coded a bit goofy but it worked before on the other host (5.5.2.1).
Here's the code for the file in question:
I basically made this to be able to change the ID's of the LI's depending on what top level page of the site you would be on.
The "_assist" & "_active" addition to the ID would trigger my css to apply some background-position changes.
I should note that I had "Enable Pretty URLs" checked. I've done a bit of searching trying to find an awnser before posting here and I believe I've read something about that pretty urls changed in some way over 5.6 (which may or may not be the cause).
I've also checked if the "_active" part would become active if I changed the " (strpos($_SERVER['PHP_SELF'], 'blog')) " to " (strpos($_SERVER['PHP_SELF'], 'index.php')) " (With pretty urls on) and it activated when testing that.
I should add that I know little to nothing about php and that I've coded this piece of php in because I found out about it through google searches of my "navigation goal" and it seemed to work at the time. I'm sure it could be done in a better way, but I wouldn't know how.
Any tips or recommendations to get the desired effect again?
Kind regards and thanks in advanced,
Michael
I've just installed a fresh copy of concrete5 (5.6.1) on a new host (My old host had version 5.5.2.1) and I'm having difficulties with getting the (custom) theme I was working on to work like it was on this new install.
The problem I'm having lies in the navigation.php element I have on my theme, which is coded a bit goofy but it worked before on the other host (5.5.2.1).
Here's the code for the file in question:
<ul> <li id="nav_blog<?php if (strpos($_SERVER['PHP_SELF'], 'blog')) echo '_active'; elseif (strpos($_SERVER['PHP_SELF'], 'about')) echo '_assist'; ?>"><a href="/blog" alt="Blog"></a></li> <li id="nav_about<?php if (strpos($_SERVER['PHP_SELF'], 'about')) echo '_active'; elseif (strpos($_SERVER['PHP_SELF'], 'freebies')) echo '_assist'; ?>"><a href="/about" alt="About"></a></li> <li id="nav_freebies<?php if (strpos($_SERVER['PHP_SELF'], 'freebies')) echo '_active'; elseif (strpos($_SERVER['PHP_SELF'], 'portfolio')) echo '_assist'; ?>"><a href="/freebies" alt="Freebies"></a></li> <li id="nav_portfolio<?php if (strpos($_SERVER['PHP_SELF'], 'portfolio')) echo '_active'; ?>"><a href="/portfolio" alt="Portfolio"></a></li> <li id="nav_home"><a href="/" alt="Home"></a></li> </ul>
I basically made this to be able to change the ID's of the LI's depending on what top level page of the site you would be on.
The "_assist" & "_active" addition to the ID would trigger my css to apply some background-position changes.
I should note that I had "Enable Pretty URLs" checked. I've done a bit of searching trying to find an awnser before posting here and I believe I've read something about that pretty urls changed in some way over 5.6 (which may or may not be the cause).
I've also checked if the "_active" part would become active if I changed the " (strpos($_SERVER['PHP_SELF'], 'blog')) " to " (strpos($_SERVER['PHP_SELF'], 'index.php')) " (With pretty urls on) and it activated when testing that.
I should add that I know little to nothing about php and that I've coded this piece of php in because I found out about it through google searches of my "navigation goal" and it seemed to work at the time. I'm sure it could be done in a better way, but I wouldn't know how.
Any tips or recommendations to get the desired effect again?
Kind regards and thanks in advanced,
Michael
Hey Adajad,
Thanks for your reply. It seems like creating a custom autonav template would be a great way to go.
I've been looking and tweaking around a bit with the custom template to see if I could get it to work like I want it to... but I'm having some difficulties.
I see that I can replace the "_active" in my css with "nav-path-selected". But I'm still figuring out how to get the "_assist" option... It's all still a bit confusing.
In any case I'm grateful for your reply, I'll keep fiddling around with the custom autonav template and see if I can get it working :).
______________________________
Edit:
I've just completed getting the nav to work on hover and on active, all I need now is to get a fix around the "assist" I had and I'm done.
currently using this for code:
navigation.php
mainmenu.php
ATTACHED AS .TXT FILE
adjusted main.css, examples:
to
etc. to match
So I'm glad I got that working, now all I need is to find of a way to tell the nav item BEFORE the active nav item to have an 'assist' class... somehow...
Any ideas?
Thanks for your reply. It seems like creating a custom autonav template would be a great way to go.
I've been looking and tweaking around a bit with the custom template to see if I could get it to work like I want it to... but I'm having some difficulties.
I see that I can replace the "_active" in my css with "nav-path-selected". But I'm still figuring out how to get the "_assist" option... It's all still a bit confusing.
In any case I'm grateful for your reply, I'll keep fiddling around with the custom autonav template and see if I can get it working :).
______________________________
Edit:
I've just completed getting the nav to work on hover and on active, all I need now is to get a fix around the "assist" I had and I'm done.
currently using this for code:
navigation.php
<?php $nav = BlockType::getByHandle('autonav'); $nav->controller->orderBy = 'display_asc'; $nav->controller->displayPages = 'top'; $nav->controller->displaySubPages = 'none'; $nav->render('templates/mainmenu'); ?>
mainmenu.php
ATTACHED AS .TXT FILE
adjusted main.css, examples:
#nav_blog_active { background-position: -460px -248px; }
to
.nav-path-selected.nav_Blog { background-position: -460px -248px; }
etc. to match
So I'm glad I got that working, now all I need is to find of a way to tell the nav item BEFORE the active nav item to have an 'assist' class... somehow...
Any ideas?
Bump
I'm afraid I still haven't been able to get this working. Any help or thoughts would be deeply appriciated.
I'm afraid I still haven't been able to get this working. Any help or thoughts would be deeply appriciated.
Have a look at the well commented code in /concrete/blocks/autonav/view.php
And also check out Jordans blogpost here explaining hardcoding options of the autonav: http://c5blog.jordanlev.com/blog/2012/04/hard-coded-autonav-options...
If you don't know how to create a custom template you can find more information here: http://www.concrete5.org/documentation/how-tos/designers/change-how...
Basically you can copy '/concrete/blocks/autonav/view.php' to '/blocks/autonav/templates/YOUR_TEMPLATE_NAME/view.php' and edit that file to your liking.