473,769 Members | 2,166 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need help to code collapsing menu

Hi,

I am trying to code a menu for a webpage, the menu is broken up to groups
i.e:

Home
Group1
Â*menuitem1
Â*menuitem2
Â*menuitem3
Group2
Â*Â*menuitem1
Â*Â*menuitem2
Â*menuitem3
And so on.

What I want to achieve is that the groups are shown in a collapsed state
depending on the page which is currently being displayed i.e so it starts
out like this

Home
Group1
Group2

If you click on Group1 it loads the first menuitem page and highlights it
and redraws the page expanding that group i.e. (note * denotes highligthed)
Home
Group1
Â*Â*menuitem1
Â*Â*Â*menuitem2
Â*Â*Â*menuitem3 Â*
Group2

And the same would apply if you click on Group2 i.e:
Home
Group1
Group2
Â*Â*menuitem1
Â*Â*Â*Â*menuite m2
Â*Â*Â*Â*menuite m3Â*

What is the best way to go about this? I have coded it 'the long way' where
there is lots of duplication of code.

I hope this all makes sense and that I have explained it clearly.

I am new to php so would really appreciate your help as I am totally at a
loss on how to best do this.

Many thanks

Rigga
Jul 17 '05
11 2287
SOR
<comp.lang.ph p , SOR , we*******@spare sorrepair.co.uk .INVALID>
<MP************ ************@no-cancel.newsread er.com>
<Sun, 10 Jul 2005 16:08:21 +0100>
inc_nav.php


Being a newbie I was curious how to do it without using stuff like
?pass=1 in the url and came up with this .

Do a cut-n-paste into inc_nav.php

<?php $filename=$_SER VER["REQUEST_UR I"]; ?>

<a href="index.php " class="butnav"> HOME</a><br>
<a href="group_one .php" class="butnav"> GROUP ONE</a><br>
<?php if ($filename=="/rigged/group_one.php") {g_one();} ?>
<a href="group_two .php" class="butnav"> GROUP TWO</a><br>
<?php if ($filename=="/rigged/group_two.php") {g_two();} ?>
<a href="index.php " class="butnav"> HOME</a><br>

<?php
function g_one()
{
print "<a href=index.php class=butnav>.. ... GROUP ONE</a><br>";
print "<a href=index.php class=butnav>.. ... GROUP ONE</a><br>";
}
?>

<?php
function g_two()
{
print "<a href=index.php class=butnav>.. ... GROUP TWO</a><br>";
print "<a href=index.php class=butnav>.. ... GROUP TWO</a><br>";
}
?>


<?php if ($filename=="/rigged/group_one.php") {g_one();} ?>

"/rigged/group_one.php"

/rigged/ being the folder name i used and you will need to adjust this
to suit your own webspace .
Jul 17 '05 #11
SOR
<comp.lang.ph p , SOR , we*******@spare sorrepair.co.uk .INVALID>
<MP************ ************@no-cancel.newsread er.com>
<Sun, 10 Jul 2005 19:51:41 +0100>
Being a newbie I was curious how to do it without using stuff like
?pass=1 in the url and came up with this .

Do a cut-n-paste into inc_nav.php

<?php $filename=$_SER VER["REQUEST_UR I"]; ?>

<a href="index.php " class="butnav"> HOME</a><br>
<a href="group_one .php" class="butnav"> GROUP ONE</a><br>
<?php if ($filename=="/rigged/group_one.php") {g_one();} ?>
<a href="group_two .php" class="butnav"> GROUP TWO</a><br>
<?php if ($filename=="/rigged/group_two.php") {g_two();} ?>
<a href="index.php " class="butnav"> HOME</a><br>


And perhaps a good reason why you shouldnt listen to a newbie .

If you clicked on a sub menu link - the sub menu would disappear .

This seems to work quite well though , Thanks for asking the question
dude as I learnt loads from doing it .


inc_nav.php

<?php $filename=$_SER VER["REQUEST_UR I"]; ?>

<?php $g1=0; $g2=0; ?>

<?php

if ($filename=="/rigged/group_one.php") {$g1=1;}
if ($filename=="/rigged/anythings.php") {$g1=1;}
if ($filename=="/rigged/bigjobbys.php") {$g1=1;}

if ($filename=="/rigged/group_two.php") {$g2=1;}
if ($filename=="/rigged/blahblahs.php") {$g2=1;}
if ($filename=="/rigged/foofoofoo.php") {$g2=1;}

?>

<a href="index.php " class="butnav"> HOME</a><br>
<a href="group_one .php" class="butnav"> GROUP ONE</a><br>
<?php if ($g1==1) {g_one();} ?>
<a href="group_two .php" class="butnav"> GROUP TWO</a><br>
<?php if ($g2==1) {g_two();} ?>
<a href="index.php " class="butnav"> HOME</a><br>

<?php
function g_one()
{
print "<a href=index.php class=butnav>.. ... GROUP ONE</a><br>";
print "<a href=index.php class=butnav>.. ... GROUP ONE</a><br>";
}
?>

<?php
function g_two()
{
print "<a href=index.php class=butnav>.. ... GROUP TWO</a><br>";
print "<a href=index.php class=butnav>.. ... GROUP TWO</a><br>";
}
?>

Jul 17 '05 #12

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

Similar topics

4
1622
by: Jeremy Epstein | last post by:
Hi guys, I've got a page that shows a number of packages available for sale. Each package has a little description, and then a (sometimes long) list of features for each package. I thought it would be a good idea to let visitors hide the details for each package, so that they can see just the summaries together. So I borrowed some code (can't remember from where), which was designed for expandable/collapsible menu trees, and used it to...
5
1894
by: Borris | last post by:
<div style="background-color: blue; width: 500px; height: 300px"> <div style="background-color: red; margin-top: 100px; margin-left: 100px; width: 300px; height: 100px"> </div> </div> Where will the red box be positioned? Even experienced web developers often expect it to be in the middle of the blue box, but instead (on standards-compliant browsers) the blue box is lowered to line up its top edge with that of the red box. This is...
2
2423
by: Stanimir Stamenkov | last post by:
I'm trying to clear some sizing issues relative to the initial containing block and the root document element. The sample document I'm trying with: http://stanio.info/viewport_fill.html Basically, for some tests I want to specify the height of an example DIV element inside the BODY using percentages of the viewport height. For this to work the BODY container should fill the viewport height where I'm using:
1
1738
by: yb | last post by:
Hi, I'm looking for clarification of css 2.1 specification in section 8.3.1 "Collapsing Margins" The 6th bullet reads "If the top and bottom margins of a box are adjoining ..." I won't paste the whole point here, its too long. But, from this first line does this mean that the element has empty
6
7387
by: Jack | last post by:
Hello, I would like some advice on how to disable the behavior of treeviews to expand and collapse when double clicked upon, but still allow the user to use the plus and minus on each node. Thanks in advance! Jack
4
3599
by: Andreas Prilop | last post by:
How many spaces should be displayed in A <span style="display:none">x</span> B between "A" and "B"? I notice that Mozilla displays one space and Internet Explorer (5 & 6) displays two spaces. See http://www.unics.uni-hannover.de/nhtcapri/temp/white-space.html for a cumulative effect. Why is this important? Instead of "span", think of the "rp" element
0
1062
by: Jack | last post by:
Hello, I am looking to denormalize XML into a few tables, does anyone know of open source software that I can use to map the collapsing and then generate the SQL ? I know xmlspy does this but looking to see if there are alternatives. My goal is to load the large XML data files into a database, but in some cases, the raw XML produces around 800 tables which is unmanageable. Thanks,
5
1963
by: SlowArrow | last post by:
Here collapsing seems to work differently in vb.net 2005 from that I use to see in vb.net 2003: Using the collapsing in vb.net 2003 shows the whole interface of the methods, subroutines, functions, etc, while in vb.net 2005 those parts after the name (arguments, etc) are missing. Is there an option to show them as well, or this is the only working method of the collapsing? What amazed me that the collapsing in the vC.net 2005 shows the...
9
1842
by: Academia | last post by:
ContextMenu has a Popup event but MainMenu does not. I need Popup with MainMenu. Do you know anyway to simulate it? Thanks in advance
0
9579
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9422
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10206
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9984
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9851
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6662
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5293
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3949
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2811
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.