Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
PHP for 'current page' indicators on menus?
Old 04-24-2005, 01:34 PM PHP for 'current page' indicators on menus?
Experienced Talker

Posts: 43
Trades: 0
I have some issues with the navigation on a page I am redesigning, and so far my attempts to find a javascript solution have only worked out partially, and it was suggested that maybe PHP would be a better approach.

Page: http://www.westeros.org/Citadel/Citadel-Frames.html

On this page, I have the main menu on the left side. Currently, I am using a javascript to unhide the appropriate submenu when the corresponding item on the main menu is clicked. I am also using javascript for onmouseover and onmouseout image changes on all the menus.

The structure of the site is such that the items on the main menu are 'virtual' groupings that do not correspond to any pages or folders (they just call up a specific submenu each). However, the items on the submenus each correspond to a directory.

What I'd like to accomplish is the following:

1) A clicked item on the main menu should remain in the 'onmouseover' state and with a non-link pointer until another item on the main menu is clicked.

2) A clicked item on the active submenu should remain in the 'onmouseover' state and with a non-link pointer until another item (main menu or submenu) is clicked.

3) When a user enters the site on an interior page, that page should load with the appropriate submenu in place and the appropriate item on the main menu and on the submenu in the 'onmouseover' state and with a non-link pointer until another item (main menu or submenu) is clicked

What I have done so far is to break out the submenus into a file that I am calling with a PHP include. I have looked some at http://www.alistapart.com/articles/keepingcurrent/ for inspiration, but it doesn't do quite what I need. I don't, for example, need a variable for each page, so could PHP be used to check which directory a page is within and display the right submenu based on that? Additionally, I need to be able to both indicate active menu & submenu item and load up the right submenu when a visitor enters on an interior page, and I am not sure what should be done in PHP and what should be done in javascript.
Linda is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-25-2005, 04:31 AM
0beron's Avatar
Defies a Status

Posts: 1,832
Location: Somewhere else entirely
Trades: 0
Well, you can either add some get variables onto the end of the URL:
'http://www.yoursite.com/page.php?c=1&s=3'
Which would represent category 1 and subcategory 3. When page.php loads, you can get back the variable values from the $_GET array that php provides:
PHP Code:
$cat $_GET['c'];
$subcat $_GET['s'];

//Code to display menu correctly given s and c. 
This would do the job, although if someone comes in from outside and doesn't specify s and c, you may have to default to s=1 c=1 or else the menu won't look right.

Another option is to store an array in a php include file that maps the filenames of the pages to the configuration of the menu. When someone loads a page, you look up which one it is, and the array tells you which category and subcategory that page is in. This involves an individual page for each subcategory, whereas the get variable version does it all in one page (at least the code is on one page, the content can be included from elsewhere).

Let us know if you ahve any further questions.
__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';

Please login or register to view this content. Registration is FREE
(aka MSN handwriting for forums)
0beron is offline
Reply With Quote
View Public Profile Visit 0beron's homepage!
 
Old 04-25-2005, 05:41 AM
Experienced Talker

Posts: 43
Trades: 0
Hrm, okay, this may have proven to be trickier than expected.

My site is using a combination of static pages and dynamic ones (the latter handled by Expression Engine), so it looks like neither of those approaches would work. Adding variables to the URLs or adding in all filenames would, as far as I can see, fail on the sections that uses EE.

Is it not possible to get PHP to work with partial URLs instead of full filenames? It would certainly be easy enough to create an array which has all the sections (http://www.domain.com/FolderOne/, http://www.domain.com/FolderTwo, and so on), and the code only needs to be able to distinguish which section a page is within, not what the precise name of a page is.
Linda is offline
Reply With Quote
View Public Profile
 
Old 04-25-2005, 09:13 AM
0beron's Avatar
Defies a Status

Posts: 1,832
Location: Somewhere else entirely
Trades: 0
That's perfectly possible - after all to tell which file or folder is in a URL you treat it as a string, so it doesn't matter if it is a folder/file/anything else.
__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';

Please login or register to view this content. Registration is FREE
(aka MSN handwriting for forums)
0beron is offline
Reply With Quote
View Public Profile Visit 0beron's homepage!
 
Old 04-25-2005, 03:08 PM
Experienced Talker

Posts: 43
Trades: 0
That sounds promising.

Could you perhaps provide an example of what such an array would look like, and what the looking up process would be like? Or point me to something I can read to try to understand it. PHP is a little bit like Greek to me so far. Except, I think I know more Greek.
Linda is offline
Reply With Quote
View Public Profile
 
Old 04-25-2005, 05:34 PM
0beron's Avatar
Defies a Status

Posts: 1,832
Location: Somewhere else entirely
Trades: 0
Creating an array uses the following syntax, although the effect is the same as defining any other variable. For this purpose I would create two arrays, one for the categories and one for the subcategories and put them in a file of their own, call it arrays.php for sake of argument.

arrays.php:
PHP Code:
$category = Array ( 'FolderOne' => 1,
                   
'FolderTwo' => 1,
                   
'FolderThree' => 2,
                   
'FolderFour' => 2,
                   
'FolderFive' => 2,
                   
'FolderSix/Subfolder1' => );

$subcategory = Array ( 'FolderOne' => 1,
                   
'FolderTwo' => 2,
                   
'FolderThree' => 1,
                   
'FolderFour' => 2,
                   
'FolderFive' => 3,
                   
'FolderSix/Subfolder1' => ); 
Then in the part of your code that creates the menu, you need to use the include() function to include arrays.php. Once you've done that the arrays get defined and you can use them. Writing $category['Folder1'] in your script will get you the value 1, and writing $subcategory['FolderFive'] will get you the value 3. This is how the looking up is done. It is exactly like arrays in just about any other programming language except php allows strings as the array indexes, not just numbers.

Now you need a way for the script to find out what folder it is running in. This can be a bit tricky but once it's working it'll be fine. The URL of the script is available in php as one of the server variables. If you run the following script:
PHP Code:

echo $_SERVER['SCRIPT_URL']; 
You will get something looking like "/SomeFolder/FolderOne/yourscript.php", ('SomeFolder' may not be there, or there may be other folders on the beginning depending on the layout of your webspace) which is almost what we want. We need to cut bits off the string to get down to just 'FolderOne' at which point you can do the array lookup and generate the right menu.

The bit at the the front is always the same length so we can use the substr() function to trim that off. Then we need to cut off the script name itself, and we can use substr again, combined with the strrpos function to find how many characters we need to trim.

This:
PHP Code:
<?php

$url 
"somefolder/FolderOne/script.php";

$trimmed1 substr($url,11);

$trimmed2 substr($trimmed1,0,strrpos($trimmed1,"/"));

echo 
$trimmed2;

?>
Should result in $trimmed2 holding just 'FolderOne'.

The 11 above is because 'somefolder/' has 11 characters in it, you'll need to adjust that number depending on how much you need to chop off.

<phew>

Let us know if you want more help as that was a fairly involved explanation.
__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';

Please login or register to view this content. Registration is FREE
(aka MSN handwriting for forums)
0beron is offline
Reply With Quote
View Public Profile Visit 0beron's homepage!
 
Old 04-26-2005, 12:04 PM
Experienced Talker

Posts: 43
Trades: 0
Haven't had a chance yet to try out creating the array and the related code, but I did finish the rest of the work needed and uploaded the new pages, to be able to have the whole navigation functional in case examples are needed.

Before I try to tackle the array, would you suggest moving any of what I am currently doing in javascript to php instead?

New Page: http://www.westeros.org/Citadel/
Javascript: http://www.westeros.org/Citadel/Mouseovers.js
Linda is offline
Reply With Quote
View Public Profile
 
Old 04-26-2005, 05:06 PM
Experienced Talker

Posts: 43
Trades: 0
I've now looked more closely at the explanation, and I must admit its way over my head.

I created this array:

Code:
$Menu = Array ( 
'Citadel' => 0,
'Citadel/FAQ' => 1,
'Citadel/SSM' => 1,
'Citadel/Concordance' => 2,
'Citadel/Encyclopaedia' => 2,
'Citadel/Heraldry' => 2,
'Citadel/History' => 2,
'Citadel/Characters' => 3,
'Citadel/Prophecies' => 3,
'Citadel/Artwork' => 4,
'Citadel/Books' => 4,
'Citadel/Images' => 4,
'Citadel/Links' => 4
);
I was thinking that I could stick this one into Menu.html (which holds the code for the Menu), and a similar one (just called SubMenu instead) into SubMenu.html, but that's about as much as I can wrap my head around. I do, btw, have .html set to parse php. But maybe the arrays need separate files anyhow?

I also tried getting the script url via that script, but without any success. However, I imagine it would be the same as the full path to the script, no? If so, its /home/sites/westeros.org/www/html/Citadel for the base directory for this section, and /home/sites/westeros.org/www/html/Citadel/<Section> for each of the sections.

I think I might have bitten off more than I can chew with this, though.
Linda is offline
Reply With Quote
View Public Profile
 
Old 04-26-2005, 06:05 PM
0beron's Avatar
Defies a Status

Posts: 1,832
Location: Somewhere else entirely
Trades: 0
I only recommended arrays in separate files in the interest of tidiness, you can write them into the menu.html and submenu.html files if you like.

What happens if, in the middle of your menu you put the code:
PHP Code:
echo $_SERVER['SCRIPT_URL']; 
What text gets displayed?

It should plonk the url of the script into your menu, but then at least you can see what it is reported to be and modify the other script to suit it.

If you can get the fullpath in php then that will work just as well, you'll just have to remove more characters from the front of the string to get down to 'Citadel/whatever'
__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';

Please login or register to view this content. Registration is FREE
(aka MSN handwriting for forums)
0beron is offline
Reply With Quote
View Public Profile Visit 0beron's homepage!
 
Old 04-26-2005, 06:22 PM
Experienced Talker

Posts: 43
Trades: 0
Since I've already broken out the menus into separate files, it'll probably be easiest to just work with the arrays within those files. That way its all out of the main page, at least.

If I just add in that code into Menu.html and then load the page, it only shows the code itself on the page. Other PHP code on the page works fine, though, such as the includes and the check on last changed date in the footer.
Linda is offline
Reply With Quote
View Public Profile
 
Old 04-26-2005, 06:48 PM
0beron's Avatar
Defies a Status

Posts: 1,832
Location: Somewhere else entirely
Trades: 0
Have you got <? ?> tags around it? Sorry, I should have specified.
__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';

Please login or register to view this content. Registration is FREE
(aka MSN handwriting for forums)
0beron is offline
Reply With Quote
View Public Profile Visit 0beron's homepage!
 
Old 04-26-2005, 07:12 PM
Experienced Talker

Posts: 43
Trades: 0
Sorry, should have mentioned that I tried that too, but then I get nothing at all returned.
Linda is offline
Reply With Quote
View Public Profile
 
Old 04-27-2005, 12:39 AM
0beron's Avatar
Defies a Status

Posts: 1,832
Location: Somewhere else entirely
Trades: 0
Odd.....
Ok, this is slight overkill, but hey. In one of your pages, put the code:
PHP Code:
<?php
print_r
($_SERVER);
?>
, and post back here with what it says.
That will echo out the entire SERVER array and then we can see what bits of it we can use. My above posts are based on what popped out of the webserver I was testing on, and yours may well be different.

I really like your site design and layout, very nice!
__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';

Please login or register to view this content. Registration is FREE
(aka MSN handwriting for forums)
0beron is offline
Reply With Quote
View Public Profile Visit 0beron's homepage!
 
Old 04-27-2005, 05:49 AM
Experienced Talker

Posts: 43
Trades: 0
Thanks. I've been working the last weeks to move everything over from tables to css, but I wanted to try and keep a fairly graphics-rich look, so it wouldn't look too modern.

I imagine it would be one of these values?

Code:
[DOCUMENT_ROOT] => /home/sites/westeros.org/www/html
[SCRIPT_FILENAME] => /home/sites/westeros.org/www/html/Citadel/index.html
[REQUEST_METHOD] => GET [QUERY_STRING] => [REQUEST_URI] => /Citadel/ 
[SCRIPT_NAME] => /Citadel/index.html 
[PHP_SELF] => /Citadel/index.html 
[PATH_TRANSLATED] => /home/sites/westeros.org/www/html/Citadel/index.html
PHP_SELF looks vaguely promising, since it seems to cut off everything up to document root.
Linda is offline
Reply With Quote
View Public Profile
 
Old 04-27-2005, 07:10 AM
0beron's Avatar
Defies a Status

Posts: 1,832
Location: Somewhere else entirely
Trades: 0
yep, see if you can use one of those. You'll need to cut off one character from the start of PHP_SELF (or else add a / to the beginning of all your array entries). The code I posted above should trim it down to just 'Citadel' in this case, at which point you can use the trimmed value to find the category number.

Light at the end of the tunnel I think
__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';

Please login or register to view this content. Registration is FREE
(aka MSN handwriting for forums)
0beron is offline
Reply With Quote
View Public Profile Visit 0beron's homepage!
 
Old 04-27-2005, 10:50 AM
Experienced Talker

Posts: 43
Trades: 0
Okay ... this is what I've got so far:

Code:
<?php 

$SubMenu = Array ( 
'/Citadel' => 0,
'/Citadel/FAQ' => 1,
'/Citadel/SSM' => 1,
'/Citadel/Concordance' => 2,
'/Citadel/Encyclopaedia' => 2,
'/Citadel/Heraldry' => 2,
'/Citadel/History' => 2,
'/Citadel/Characters' => 3,
'/Citadel/Prophecies' => 3,
'/Citadel/Artwork' => 4,
'/Citadel/Books' => 4,
'/Citadel/Images' => 4,
'/Citadel/Links' => 4
); 

$url = "echo $_SERVER['PHP_SELF']";

$folders = substr($url,0,strrpos($url,"/"));

echo $folders; 

if ($SubMenu['$folders']=="0")
echo ""

if ($SubMenu['$folders']=="1")
echo
"
<div id="MenuQA">
<a href="http://www.westeros.org/Citadel/FAQ/" onmouseover="changeImages('qa01','qa01b')" onmouseout="changeImages('qa01','qa01a')"><img class="MenuItem" name="qa01" src="http://www.westeros.org/Citadel/Graphics/menu_qa01a.gif" width="99" height="40" border="0" alt="FAQ" title="FAQ" /></a>
<a href="http://www.westeros.org/Citadel/SSM/" onmouseover="changeImages('qa02','qa02b')" onmouseout="changeImages('qa02','qa02a')"><img class="MenuItem" name="qa02" src="http://www.westeros.org/Citadel/Graphics/menu_qa02a.gif" width="99" height="40" border="0" alt="So Spake Martin" title="SoSpakeMartin" /></a>
</div>
"

if ($SubMenu['$folders']=="2")
echo
"
<div id="MenuTheme">
<a href="http://www.westeros.org/Citadel/Concordance/" onmouseover="changeImages('theme01','theme01b')" onmouseout="changeImages('theme01','theme01a')"><img class="MenuItem" name="theme01" src="http://www.westeros.org/Citadel/Graphics/menu_theme01a.gif" width="99" height="40" border="0" alt="Concordance" title="Concordance" /></a>
<a href="http://www.westeros.org/Citadel/Encyclopaedia/" onmouseover="changeImages('theme02','theme02b')" onmouseout="changeImages('theme02','theme02a')"><img class="MenuItem" name="theme02" src="http://www.westeros.org/Citadel/Graphics/menu_theme02a.gif" width="99" height="40" border="0" alt="Encyclopaedia" title="Encyclopaedia" /></a>
<a href="http://www.westeros.org/Citadel/Heraldry/" onmouseover="changeImages('theme03','theme03b')" onmouseout="changeImages('theme03','theme03a')"><img class="MenuItem" name="theme03" src="http://www.westeros.org/Citadel/Graphics/menu_theme03a.gif" width="99" height="40" border="0" alt="Heraldry" title="Heraldry" /></a>
<a href="http://www.westeros.org/Citadel/History/" onmouseover="changeImages('theme04','theme04b')" onmouseout="changeImages('theme04','theme04a')"><img class="MenuItem" name="theme04" src="http://www.westeros.org/Citadel/Graphics/menu_theme04a.gif" width="99" height="40" border="0" alt="History" title="History" /></a>
</div>
"

if ($SubMenu['$folders']=="3")
echo
"
<div id="MenuStory">
<a href="http://www.westeros.org/Citadel/Characters/" onmouseover="changeImages('story01','story01b')" onmouseout="changeImages('story01','story01a')"><img class="MenuItem" name="story01" src="http://www.westeros.org/Citadel/Graphics/menu_story01a.gif" width="99" height="40" border="0" alt="Characters" title="Characters" /></a>
<a href="http://www.westeros.org/Citadel/Prophecies/" onmouseover="changeImages('story02','story02b')" onmouseout="changeImages('story02','story02a')"><img class="MenuItem" name="story02" src="http://www.westeros.org/Citadel/Graphics/menu_story02a.gif" width="99" height="40" border="0" alt="Prophecies" title="Prophecies" /></a>
</div>
"

if ($SubMenu['$folders']=="4")
echo
"
<div id="MenuMiscellany">
<a href="http://www.westeros.org/Citadel/Artwork/" onmouseover="changeImages('miscellany01','miscellany01b')" onmouseout="changeImages('miscellany01','miscellany01a')"><img class="MenuItem" name="miscellany01" src="http://www.westeros.org/Citadel/Graphics/menu_miscellany01a.gif" width="99" height="40" border="0" alt="Artwork" title="Artwork" /></a>
<a href="http://www.westeros.org/Citadel/Books/" onmouseover="changeImages('miscellany02','miscellany02b')" onmouseout="changeImages('miscellany02','miscellany02a')"><img class="MenuItem" name="miscellany02" src="http://www.westeros.org/Citadel/Graphics/menu_miscellany02a.gif" width="99" height="40" border="0" alt="Books" title="Books" /></a>
<a href="http://www.westeros.org/Citadel/Images/" onmouseover="changeImages('miscellany023','miscellany03b')" onmouseout="changeImages('miscellany03','miscellany03a')"><img class="MenuItem" name="miscellany03" src="http://www.westeros.org/Citadel/Graphics/menu_miscellany03a.gif" width="99" height="40" border="0" alt="Images" title="Images" /></a>
<a href="http://www.westeros.org/Citadel/Links/" onmouseover="changeImages('miscellany04','miscellany04b')" onmouseout="changeImages('miscellany04','miscellany04a')"><img class="MenuItem" name="miscellany04" src="http://www.westeros.org/Citadel/Graphics/menu_miscellany04a.gif" width="99" height="40" border="0" alt="Links" title="Links" /></a>
</div>
"

?>
This, however, throws the following error:

Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/sites/westeros.org/www/html/Citadel/Citadel-Submenus.html on line 19

That would be this:

Code:
$url = "echo $_SERVER['PHP_SELF']";
I don't doubt that there are some crazy mistakes in the above code, though, as I am partly guessing at how to put this together. But the basic idea, if I've understood it correctly, would be to use the numerical value corresponding to a particular URL to display a particular menu.

I have a feeling this will conflict with the javascript I am currently using to allow the submenu switching, but if I get this part working, I can tackle that problem afterwards.
Linda is offline
Reply With Quote
View Public Profile
 
Old 04-27-2005, 03:50 PM
0beron's Avatar
Defies a Status

Posts: 1,832
Location: Somewhere else entirely
Trades: 0
You've got the right idea, there's just a few problems with your syntax in places. On line 19 itself, all you need it
PHP Code:
$url $_SERVER['PHP_SELF']; 
'echo' is part of PHP, so putting it inside a string causes it to be treated as just the word echo.

When indexing into an array using a variable or a number, you don't need quotes:

PHP Code:
$array = Array ( 0=> 'zero''string' => 'otherstring');

echo 
$array[0];
echo 
$array['string'];
$var 'string';
echo 
$array[$var]; //No quotes needed here 
Later on you have trouble with " marks in your html - the first " it finds terminates the string, and the html that follows is treated as php again. If you ever have big blocks of output that you want to control with an if statement or similar, the best and most readable way of doing it is to drop out of php and back in again:

PHP Code:

if($print_it==1) { ?> 
<html>
<body>
<span style="color:blue;">Long block of text, with quotes as normal.....
</span>
</body>
</html>

<? }
The above code is works fine - anything outside the <? ?> tags is sent straight to the browser, but only if that part of the code gets evaluated.

Also make sure that all your statements have a ; at the end - for example the line echo "" needs one.

So making the above corrections, you end up with this:
PHP Code:
<?php

$SubMenu 
= Array (
                  
'/Citadel' => 0,
                  
'/Citadel/FAQ' => 1,
                  
'/Citadel/SSM' => 1,
                  
'/Citadel/Concordance' => 2,
                  
'/Citadel/Encyclopaedia' => 2,
                  
'/Citadel/Heraldry' => 2,
                  
'/Citadel/History' => 2,
                  
'/Citadel/Characters' => 3,
                  
'/Citadel/Prophecies' => 3,
                  
'/Citadel/Artwork' => 4,
                  
'/Citadel/Books' => 4,
                  
'/Citadel/Images' => 4,
'/Citadel/Links' => 4
                  
);

$url $_SERVER['PHP_SELF'];

$folders substr($url,0,strrpos($url,"/"));

echo 
$folders;

if (
$SubMenu[$folders]=="0")
     echo 
"";

     if (
$SubMenu[$folders]=="1") { ?>

<div id="MenuQA">
<a href="http://www.westeros.org/Citadel/FAQ/" onmouseover="changeImages('qa01','qa01b')" onmouseout="changeImages('qa01','qa01a')"><img class="MenuItem" name="qa01" src="http://www.westeros.org/Citadel/Graphics/menu_qa01a.gif" width="99" height="40" border="0" alt="FAQ" title="FAQ" /></a>
<a href="http://www.westeros.org/Citadel/SSM/" onmouseover="changeImages('qa02','qa02b')" onmouseout="changeImages('qa02','qa02a')"><img class="MenuItem" name="qa02" src="http://www.westeros.org/Citadel/Graphics/menu_qa02a.gif" width="99" height="40" border="0" alt="So Spake Martin" title="SoSpakeMartin" /></a>
</div>
   <? }

if (
$SubMenu[$folders]=="2") { ?>
<div id="MenuTheme">
<a href="http://www.westeros.org/Citadel/Concordance/" onmouseover="changeImages('theme01','theme01b')" onmouseout="changeImages('theme01','theme01a')"><img class="MenuItem" name="theme01" src="http://www.westeros.org/Citadel/Graphics/menu_theme01a.gif" width="99" height="40" border="0" alt="Concordance" title="Concordance" /></a>
<a href="http://www.westeros.org/Citadel/Encyclopaedia/" onmouseover="changeImages('theme02','theme02b')" onmouseout="changeImages('theme02','theme02a')"><img class="MenuItem" name="theme02" src="http://www.westeros.org/Citadel/Graphics/menu_theme02a.gif" width="99" height="40" border="0" alt="Encyclopaedia" title="Encyclopaedia" /></a>
<a href="http://www.westeros.org/Citadel/Heraldry/" onmouseover="changeImages('theme03','theme03b')" onmouseout="changeImages('theme03','theme03a')"><img class="MenuItem" name="theme03" src="http://www.westeros.org/Citadel/Graphics/menu_theme03a.gif" width="99" height="40" border="0" alt="Heraldry" title="Heraldry" /></a>
<a href="http://www.westeros.org/Citadel/History/" onmouseover="changeImages('theme04','theme04b')" onmouseout="changeImages('theme04','theme04a')"><img class="MenuItem" name="theme04" src="http://www.westeros.org/Citadel/Graphics/menu_theme04a.gif" width="99" height="40" border="0" alt="History" title="History" /></a>
</div>
   <? }

if (
$SubMenu[$folders]=="3") { ?>
<div id="MenuStory">
<a href="http://www.westeros.org/Citadel/Characters/" onmouseover="changeImages('story01','story01b')" onmouseout="changeImages('story01','story01a')"><img class="MenuItem" name="story01" src="http://www.westeros.org/Citadel/Graphics/menu_story01a.gif" width="99" height="40" border="0" alt="Characters" title="Characters" /></a>
<a href="http://www.westeros.org/Citadel/Prophecies/" onmouseover="changeImages('story02','story02b')" onmouseout="changeImages('story02','story02a')"><img class="MenuItem" name="story02" src="http://www.westeros.org/Citadel/Graphics/menu_story02a.gif" width="99" height="40" border="0" alt="Prophecies" title="Prophecies" /></a>
</div>
   <? }

if (
$SubMenu[$folders]=="4") { ?>
<div id="MenuMiscellany">
<a href="http://www.westeros.org/Citadel/Artwork/" onmouseover="changeImages('miscellany01','miscellany01b')" onmouseout="changeImages('miscellany01','miscellany01a')"><img class="MenuItem" name="miscellany01" src="http://www.westeros.org/Citadel/Graphics/menu_miscellany01a.gif" width="99" height="40" border="0" alt="Artwork" title="Artwork" /></a>
<a href="http://www.westeros.org/Citadel/Books/" onmouseover="changeImages('miscellany02','miscellany02b')" onmouseout="changeImages('miscellany02','miscellany02a')"><img class="MenuItem" name="miscellany02" src="http://www.westeros.org/Citadel/Graphics/menu_miscellany02a.gif" width="99" height="40" border="0" alt="Books" title="Books" /></a>
<a href="http://www.westeros.org/Citadel/Images/" onmouseover="changeImages('miscellany023','miscellany03b')" onmouseout="changeImages('miscellany03','miscellany03a')"><img class="MenuItem" name="miscellany03" src="http://www.westeros.org/Citadel/Graphics/menu_miscellany03a.gif" width="99" height="40" border="0" alt="Images" title="Images" /></a>
<a href="http://www.westeros.org/Citadel/Links/" onmouseover="changeImages('miscellany04','miscellany04b')" onmouseout="changeImages('miscellany04','miscellany04a')"><img class="MenuItem" name="miscellany04" src="http://www.westeros.org/Citadel/Graphics/menu_miscellany04a.gif" width="99" height="40" border="0" alt="Links" title="Links" /></a>
</div>
   <? }

?>
(I haven't tested this so I might have missed something).

Let me know if there are any other questions
__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';

Please login or register to view this content. Registration is FREE
(aka MSN handwriting for forums)
0beron is offline
Reply With Quote
View Public Profile Visit 0beron's homepage!
 
Old 04-27-2005, 04:15 PM
Experienced Talker

Posts: 43
Trades: 0
Definitely closer, but not quite there yet. With that setup I get, for example, /Citadel/Characters/ displayed when I load up a page in that folder. So just the value of $folders, but not the actual menu.

I am really grateful for all the help, btw.
Linda is offline
Reply With Quote
View Public Profile
 
Old 04-28-2005, 04:21 AM
0beron's Avatar
Defies a Status

Posts: 1,832
Location: Somewhere else entirely
Trades: 0
Are you certain that what gets displayed has that / on the end? When I test it, the slash gets taken off by the substr function. You can either add a / to the end of your array entries, or make the last argument ofthe substr function call one smaller :
PHP Code:
$folders substr($url,0,strrpos($url,"/")-1); 
__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';

Please login or register to view this content. Registration is FREE
(aka MSN handwriting for forums)
0beron is offline
Reply With Quote
View Public Profile Visit 0beron's homepage!
 
Old 04-28-2005, 05:29 AM
Experienced Talker

Posts: 43
Trades: 0
Ah, you're right, there's no slash at the end. Adding a slash to the end of the array entries still only displays the text of the entry, though.

Edited to add: Taking out the 'echo $folders' bit removes the stray text, and the fact that the menu didn't show up was due to the CSS (since it was set to hide the menu until unhidden through javascript). Now I just need to get the javascript and the PHP to play nice together, to allow for auto-loading of menus and manual toggling. But I've got some ideas to try.

Last edited by Linda; 04-28-2005 at 07:05 AM..
Linda is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to PHP for 'current page' indicators on menus?

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.89408 seconds with 12 queries