Conditional for first level nav
Permalink
Hi all,
I'm trying to build a navigation where a list item is green when the user is on the parent page or child pages of that parent.
I can't seem to find it anywhere on the forums, though I'm sure it's been answered before. Any help is much appreciated!
OH PS, important note! The nav is NOT dynamic or from a block, it's static. Is there a way to create conditional CSS for this?
I'll try using this:
But I'm afraid that the client may down the road change the collection ID. Is there a way to make it across the board so that any time you're on [blah] page, that first level list items gets, say, "selected" added to the HTML?
Edit: I added this, in a pinch, but I know this is pretty bad. Any changes are very very welcome:
I'm trying to build a navigation where a list item is green when the user is on the parent page or child pages of that parent.
I can't seem to find it anywhere on the forums, though I'm sure it's been answered before. Any help is much appreciated!
OH PS, important note! The nav is NOT dynamic or from a block, it's static. Is there a way to create conditional CSS for this?
I'll try using this:
if ($c->getCollectionID == 1){ echo 'homepage content'; // whatever you want here }
But I'm afraid that the client may down the road change the collection ID. Is there a way to make it across the board so that any time you're on [blah] page, that first level list items gets, say, "selected" added to the HTML?
Edit: I added this, in a pinch, but I know this is pretty bad. Any changes are very very welcome:
$("li.month ul.monthsPages li.monthsPage a").each(function() { var $this = $(this); if ($this.html() === "2010" || $this.html() === "2011" || $this.html() === "2012" || $this.html() === "2013" || $this.html() === "2014" || $this.html() === "2015" || $this.html() === "2016" || $this.html() === "2017" || $this.html() === "2018" || $this.html() === "2019" || $this.html() === "2020") { $this.parent().remove(); } if ($this.html() === "1" || $this.html() === "2" || $this.html() === "3" || $this.html() === "4" || $this.html() === "5" || $this.html() === "6" || $this.html() === "7" || $this.html() === "8" || $this.html() === "9" || $this.html() === "10" || $this.html() === "11" || $this.html() === "12") { $this.parent().remove(); } });