Jump to content

Selecting 'a' class


Recommended Posts

Hey Guys,

 

I'm trying to apply a class to a link based on the page for the site navigation. I tried what I would usually do in this instance, but it just appears as text on the page. Is there any way I can achieve this?

 

Here's what I have:

 

Head:

 

<?php $page = basename($_SERVER['SCRIPT_NAME']); ?>

 

then the link;

 

<li><a <?php if ($page == 'clientarea.php?action=invoices') { ?>class="current"<?php } ?> href="clientarea.php?action=invoices">Invoices</a> </li>

 

What I am trying to get as the end result:

 

the page is clientarea.php?action=invoices, then the link is <li><a class="current" href="clientarea.php?action=invoices">Invoices</a> </li>

 

Thanks!

 

Matt

http://www.hostnexus.com.au

Link to comment
Share on other sites

Hi sparky,

 

I am applying the class to a <li> item, and when I view the source of the document, it does not appear at all:

 

<li> <a (where it should be) href="#">Billing</a>

 

<ul>

 

<li><a href="clientarea.php?action=invoices">Invoices</a> </li>

 

Any ideas? I know I am applying the right class in the right place, as it works if I just make it static.

 

Matt

http://www.hostnexus.com.au

Link to comment
Share on other sites

Is this the one you mean?

#topnav ul li .current {

color:#39c;

background:transparent url(../../images/skin7/topnavBG.png) -100px -76px no-repeat;

}

 

If so then you are not referencing the the <a> tag at all.

 

If not then please supply a url to the nav menu in question or post the css involved and the html for the area you need the help on.

 

Give some detailed info and you should be able to get the answer that you are after!

Link to comment
Share on other sites

Hi sparky,

 

Thanks very much for your help, I have created a testing account for you: e: test@hostnexus.com.au p: sparky url: https://manage.hostnexus.com.au/clientarea.php

 

You will see the navigation menu up the top of the page, in a 'tab' style. You will see that I am wanting to get the 'Client Area', 'Billing', 'Services', and 'Support' tabs to be the current class when the pages below them are selected.

 

Thanks once again,

 

Matt

http://www.hostnexus.com.au

Link to comment
Share on other sites

Your css is working fine... it's your scripting

When you click on billing and then invoices the current class name is assigned to clientarea instead of billing.

 

My issue is, though, that the nav is contained within the header.tpl file, so I need some way to dynamically change it. I cannot assign a class for every page because of this.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated