So I have my navbar:
What I want to do is... if the user is on index.php then 'latest post's in the navbar turns red, if the user is on ideas.php then 'ideas' in the navbar turns orange, if the user is on facts.php then 'facts' in the navbar turns yellow.
When one of these navbar words changes the colour, the rest still are white.
[syntax=xhtml]<div id="navbar">
<ul>
<li><a class = "latest_posts_nav" href="index.php">latest posts</a></li>
<li>|</li>
<li><a class = "ideas_nav" href="ideas.php">ideas</a></li>
<li>|</li>
<li><a class = "facts_nav" href="facts.php">facts</a></li>
<li>|</li>
<li><a class = "quotes_nav" href="quotes.php">quotes</a></li>
<li>|</li>
<li><a class = "articles_nav" href="articles.php">articles</a></li>
<li>|</li>
<li><a class = "images_nav" href="images.php">images</a></li>
</ul>
</div>[/syntax]
I presume it's javascript of some sort?
How to change a word colour (a link) in navbar when clicked?
Re: How to change a word colour (a link) in navbar when clic
I would probably do this with php actually. Add a class to the link for the current page, something like this
[syntax=php]<li><a class = "latest_posts_nav <?php if ($page === 'index') echo 'selected'; ?>" href="index.php">latest posts</a></li>
<li>|</li>
<li><a class = "ideas_nav<?php if ($page === 'ideas') echo ' selected'; ?>" href="ideas.php">ideas</a></li>
<li>|</li>[/syntax]
then you can just style it with css.
[syntax=php]<li><a class = "latest_posts_nav <?php if ($page === 'index') echo 'selected'; ?>" href="index.php">latest posts</a></li>
<li>|</li>
<li><a class = "ideas_nav<?php if ($page === 'ideas') echo ' selected'; ?>" href="ideas.php">ideas</a></li>
<li>|</li>[/syntax]
then you can just style it with css.
Re: How to change a word colour (a link) in navbar when clic
I'm confused as to how/what I'd be setting the $page variable as?
Re: How to change a word colour (a link) in navbar when clic
There must be something that contains the name of the current page ? Maybe $_GET['page'] ? However your template system is set up
Re: How to change a word colour (a link) in navbar when clic
jacek wrote:There must be something that contains the name of the current page ? Maybe $_GET['page'] ? However your template system is set up
Yeah I just through of that, I want to know as well...if you go to my site the index.php is not actually in the URL, if i use the get method will it pick it up?
Re: How to change a word colour (a link) in navbar when clic
Yeah it should still work, as long as you use the right string in the if statement.
If $page contains "index" don't do
[syntax=php]if ($page === 'index.php')[/syntax]
because that will obviously never be true.
If $page contains "index" don't do
[syntax=php]if ($page === 'index.php')[/syntax]
because that will obviously never be true.
Re: How to change a word colour (a link) in navbar when clic
Sweet, think i got it working!!
Cheers dude, was really smart thinking there
Cheers dude, was really smart thinking there