Jump to content
xisto Community
Ahsaniqbalkmc

Change The Appearance Of Link That Links To Current Page

Recommended Posts

I have a <ul> of links right at the top of my website that display links to the main pages of my website.I want to change the appearance of the link that is linking to currently open page so that it gets a little bolder and no more remains a link.For example I have 3 links "Page1, Page2, Page3" in the <ul>. Now when someone clicks on link "Page1" and Page number 1 opens, then the link "page1" should become a little bolder and not remain a link,What php code can let me accomplish the effect. For information, I am using wordpress.

Share this post


Link to post
Share on other sites

You can use css to do this.

A:link {text-decoration: underline;} /*unvisited links*/A:visited {text-decoration: none;}/*visited links.*/A:active {text-decoration: none;} /*active links*/A:hover {text-decoration: underline; color: red;}/*hovered links*/

Please note, you can't change the order of these 4.

Share this post


Link to post
Share on other sites

I think what he wants is to make the link to the current open page unclickable. 1. Read the current location using the $_SERVER php vriable array. There are lots of documents available as reference around the web, i am leaving that up to you to search. TAKE NOTE: php.net website documentations are not newbie friendly in fact they are mostly written for very technical people.2. Do a comparison with the list of URL links on your site and the current captured active link. you can use strcmp (you can google for this one too) command from PHP or you can use preg_match (a faster shortcode comparison from PHP). TAKE NOTE: preg_match is a very fast and efficient string comparison but also a pain in the head to understand the first time.

Share this post


Link to post
Share on other sites

Theres another easier option, but will definitely but not manageable if the site is huge...IF the site is small, around 10 pages, just edit the html file for each one! remove the anchor of the unneeded link, which will remove the hyperlink, and just display text. btw, an anchor is <a> and ends with </a>

Share this post


Link to post
Share on other sites

Theres another easier option, but will definitely but not manageable if the site is huge...
IF the site is small, around 10 pages, just edit the html file for each one! remove the anchor of the unneeded link, which will remove the hyperlink, and just display text. btw, an anchor is <a> and ends with </a>


He already said that he is using wordpress.

Share this post


Link to post
Share on other sites

I think what he wants is to make the link to the current open page unclickable.

 

 

1. Read the current location using the $_SERVER php vriable array. There are lots of documents available as reference around the web, i am leaving that up to you to search. TAKE NOTE: php.net website documentations are not newbie friendly in fact they are mostly written for very technical people.

 

2. Do a comparison with the list of URL links on your site and the current captured active link. you can use strcmp (you can google for this one too) command from PHP or you can use preg_match (a faster shortcode comparison from PHP). TAKE NOTE: preg_match is a very fast and efficient string comparison but also a pain in the head to understand the first time.

Thank you for showing me some light.

I have done a little search on google and I am thinking of "strcmp" as the possible solution but I cannot figure it out completely.

Have a look at the following code.

$home="<a href="http://www.mananatomy.com/ href="http://www.mananatomy.com/about href="http://www.mananatomy.com/contact (strcmp("index.php" $currentpage)) {$home="home"} else if (strcmp("mananatomy.com/about" $currentpage)) {$about="About"} else (strcmp("mananatomy.com/contact" $currentpage)) {$contact="Contact"}
I know there are some problems with the code but I can't figure them out. I am not clear about the following points.

1. what will be the format of value returned by "$_SERVER[php_SELF]" for pages that have no extension for example http://www.mananatomy.com/about

2. Suppose I get it right in this way by making the links as php variables, then how will I apply all the css that is currently applied to "ul.menu a".

Share this post


Link to post
Share on other sites

The code that you got from google looks fine to me. It just needs to be changed as per your requirement and the way theme works. Make sure you change CSS of the theme as well. CSS will make sure that you don't have any text-decoration( like links) attached to the theme. You can then bold the link.visited{ } part in CSS. Also do the necessary changes. I hope i got what you're asking so far. Sorry for the late reply, i was offline for few weeks so unable to get to reply you.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.