HOME       >>       Programming

Change The Appearance Of Link That Links To Current Page


Ahsaniqbalkmc

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.


imjjss

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.


vhortex

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.


derekchoi2

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>


vhortex

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.

derekchoi2

ahh whoops..... sorry about thatcause i had the same issue, but i was dealing with html files...never had experience with wordpress, sorry D:


vhortex

It is fine, that will be an added info for him. Just reminding you on the blogging script that he is using.


derekchoi2

thats cool, maybe i should give wordpress a try


Ahsaniqbalkmc

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".


mahesh2k

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.



VIEW ORIGINAL REGISTER GET FREE HOSTING

Xisto.com offers Free Web Hosting to its Members for their participation in this Community. We moderate all content posted here but we cannot warrant full correctness of all content. While using this site, you agree to have read and accepted our terms of use, cookie and privacy policy. Copyright 2001-2019 by Xisto Corporation. All Rights Reserved.