473,396 Members | 1,765 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Need some help with a menu-bar function

I often use a function to create a list of links that are included in
several sites and disable the link that refers to the site itself

<?php
function maakZoNodigLink($omschrijving, $verwijzing)
{
$locatie = $_SERVER['PHP_SELF'];
if (strstr($locatie, $verwijzing)) //actual page
should not be linked
echo $omschrijving."<br>\n";
else echo ("<a href = \"$verwijzing\">$omschrijving</a><br>\n"); //other
pages are linked }
?>

Somewhere else in the page I do something like:
<?php
maakZoNodigLink("Hoofdpagina","main.php");
maakZoNodigLink("Geschiedenis", "gesch.php");
?>

Although it works okay, I have to do some editing when I use the function
for another site. E.g. in this example every link is followed by a <br> and
when want to create a menu bar like [home][hobby's][contact] and the actual
link should not be underlined, I have to realise a lot of changes *within*
the function itself.
I have been thinking about possibilities to create an additional variable
like $separator = "<br>" but I don't know where to locate it. Besides I
wonder if there is a more efficient way then callling the maakZoNodigLink
function several times, as I do in the example above.
Would like some feedback because I have the feeling that I am doing things
in a more complicated way then I should do :-)
Thanks for any help,

Martien van Wanrooij
Jul 17 '05 #1
2 1826
"Martien van Wanrooij" <in**@martienvanwanrooij.nl> wrote:
<?php
function maakZoNodigLink($omschrijving, $verwijzing)
{
$locatie = $_SERVER['PHP_SELF'];
if (strstr($locatie, $verwijzing))
echo $omschrijving."<br>\n";
else echo ("<a href = \"$verwijzing\">$omschrijving</a><br>\n");
//other
pages are linked }
?>

Although it works okay, I have to do some editing when I use the
function for another site. E.g. in this example every link is followed
by a <br> and when want to create a menu bar like
[home][hobby's][contact] and the actual link should not be underlined,


You could add a parameter which has a default value, e.g.:

function maakZoNodigLink($omschrijving, $verwijzing, $separator="<br
/>")
{
$locatie = $_SERVER['PHP_SELF'];
if (strstr($locatie, $verwijzing))
echo $omschrijving.$separator."\n";
else echo ("<a href = \"$verwijzing\">$omschrijving</a>".
$separator."\n");
}

If you want to change the layout, give the additional parameter with a
different separator, e.g.:

echo "[";
maakZoNodigLink("Hoofdpagina","main.php", "][");
maakZoNodigLink("Geschiedenis", "gesch.php", "]");

The original call to the function will still work as well:
maakZoNodigLink("Geschiedenis", "gesch.php");

HTH;
JOn


HTH;
JOn
Jul 17 '05 #2

"Jon Kraft" <jo*@jonux.co.uk> schreef in bericht
news:Xn**************************@130.133.1.17...
You could add a parameter which has a default value, e.g.:

function maakZoNodigLink($omschrijving, $verwijzing, $separator="<br
[...] If you want to change the layout, give the additional parameter with a
different separator, e.g.:
echo "[";
The original call to the function will still work as well:
maakZoNodigLink("Geschiedenis", "gesch.php");

Thank you John, this really helps a lot :-)

Martien.
Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: VP | last post by:
G'day folks, well i am attempting to get an understanding on how to create the menuitems in a context menu on the fly. So far I have managed to actually achieve the menu items being created for...
2
by: Mayolo Juarez via DotNetMonster.com | last post by:
Hi, I have a problem, when i use a context menu in a MDIForm and activate the property "MDIList= True", the context menu don't show me the current child windows, please help me, i use VS2003. ...
5
by: Joe | last post by:
Hi, I would like to create a vertical and horizontal navigation menu for a asp.net pages. I have been looking over the internet but I haven’t seen a decent free code that I can take and...
0
by: T. J. Fan | last post by:
I was trying to call from a web page a routine defined in another page (to reload that page). More specifically, I need to be able to reload the first page after user did something on the second...
24
by: Rhino | last post by:
I am dabbling with print CSS for the first time and I need some guidance. The web pages on my site look fine - to my untrained eye - when displayed on the monitor in any of the standard browsers....
2
by: bj | last post by:
Hi, Yes, this is yet another "switching from tables to divs for layout purposes" post. I have been searching for the past few hours to find what I'm looking for as I hate posting unnecessarily....
1
by: leahleah | last post by:
hi, i am a beginner when it comes to javascript, i would like to have a menu (see examples 1 and 2 below), that folds out to reveal sub links, pushing the other menu items down – and then springs...
1
by: ynnejneib | last post by:
Please Help Me Have A Case Study And It Is The First Time Taking C++ We Dont Know How To Start It Sause Here's Our Topic.. We Need 5 Main Menu's The 1st Menu Is Weekday..if The User...
0
by: =?Utf-8?B?QnJpYW4gS2l0dA==?= | last post by:
I am trying to develop a right click context menu for a browser help object. I have the browser help object done and working fine, but cannot get the context menu to work. I know about MenuExt...
2
by: jdvictor | last post by:
Understandably I know that the real issue is in IE but at the moment everything looks good in IE and not Firefox. THE PROBLEM The problem that I am having is that my navigation menu is out of...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.