You are here: Re: How to disable link to current page? « All PHP « IT news, forums, messages
Re: How to disable link to current page?

Posted by J.O. Aho on 04/07/07 12:43

H@C0 wrote:
> On Sat, 07 Apr 2007 00:21:39 GMT, boclair <boclair@bigpond.net.au> wrote:
>
> Thanks for your response.
> I have something like this with image links:
>
> <?php
> $thisfile=(basename ($_SERVER['PHP_SELF']));
>
> if ($thisfile=="page1.php")
> {$page1="style='display:none;'";}
> else {$page1="";}
>
> if ($thisfile=="page2.php")
> {$page2="style='display:none;'";}
> else {$page2="";}
> ?>
>
> <a href="page1.php" <img src="img1.jpg"></a>
> <a href="page2.php" <img src="img2.jpg"></a>
>
> But I want the link of the current page to be unckickable and the mouse
> pointer to be default. Any hints?


First of all, in case you haven't already done this, I would lift out the menu
to it's own php file, then you have only one place to change things at,
instead of X number of pages.

--- menu.php ---
<?PHP
function typeLink($page,$img,$title="",$alt="link image") {
if(basename ($_SERVER['PHP_SELF']) == $page)
return "<div class=\"nolnk\"><img src=\"{$img}\" alt=\"{$alt\"
title=\"{$title}\"></div>";
return "<div class=\"lnk\"><a href=\"{$page}\"><img src=\"{$text}\"
alt=\"{$alt}\" title=\"{$title}\"></a>/div>";
}

echo typeLink('page1.php','someimage1.png','Page 1');
echo typeLink('page2.php','someimage2.png','Page 2');
echo typeLink('page3.php','someimage3.png','Page 3');
?>
--- eof ---

and in the file where you want the menu, place the following where the menu is
supposed to be placed

<?PHP include('menu.php'); ?>


If you want to change the pointer, then edit the css classes nolnk and/or lnk,
if you are using xhtml, then add a / at the end of the img tag.

I'm not supplying any different alt values, as alt are just used to tell
something about the image if it's not loaded, title is used if you want a
small tool tips displayed when the pointer is placed over the image.

--

//Aho

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация