Jump to content

Help with a php menu system...


Hitman247m

Recommended Posts

I've been thinking about different ways I could set up the side navigation menu on my site, and I found a system that I think I would like to use.

 

 

 

It looks something like this:

 

menulr9.jpg

 

You can see a live example on http://www.invisionpower.com

 

 

 

In this menu system, there are different categories that remain collapsed, untill they are clicked on. When they are clicked on, a new page loads in the browser, the home page for that category, and that category of links is expanded, while all the others are collapsed.

 

 

 

I have the framework of the system layed out in my head, but I'm not quite sure how to code it, so I'm turing to the PHP pros on Tip.it :)

 

 

 

The main thing I would like his script to do is that in the template, I would like to be able to declare a variable, and set the value to a number (1,2,3, etc..) that would correspond with the category (category 1 being home, category 2 being 'News and Press', and so on).

 

 

 

The other problem I'm having with the coding thus far is I'm not sure how I would go about hiding sections of the menu (for the collapsed parts).

 

 

 

 

 

Thanks in advance, and if you need me to clear something up, just ask :thumbsup:

Hitman247m.png
Link to comment
Share on other sites

php? it can be done with javascript.

 

in the

:

 




 

then in the

:

 



siggyanimatoin5dtbp3.gif

There are 10 types of people: Those who understand binary, and those who don't.

Appreciate Bacteria! It's the only form of culture some people have.

The brain's right side controls the body's left, so only lefties are in their right mind.

School!

Link to comment
Share on other sites

Thanks, only reason I wanted php was so I could declare the category on each page independantly of that script, so, uh, heres the code im usuing for each page:

 

 

 

<?php 



// Adress Error Handling

ini_set ('display_errors', 1);

error_reporting (E_ALL & ~E_NOTICE);



// Page Title

define ('TITLE', 'Hitman Central');



// Category

$category = 1;



// Require Page Header

require ('header.html');



?>







page contents







<?php



// Require Page Footer

require ('footer.html');



?>

 

 

 

So, uh, say I'm on a page in the "Home" category (#1) when that page loads, that menu will be explanded, while all the others are collapsed.

 

 

 

I'm using this template-type system, so I declare variables on pages like this, and it injects that code into the newly rendered page.

Hitman247m.png
Link to comment
Share on other sites

your code doesn't have a menu at all, unless it is in header or footer.html, but then $category wouldn't help you...

siggyanimatoin5dtbp3.gif

There are 10 types of people: Those who understand binary, and those who don't.

Appreciate Bacteria! It's the only form of culture some people have.

The brain's right side controls the body's left, so only lefties are in their right mind.

School!

Link to comment
Share on other sites

you can't have php in .html files...

siggyanimatoin5dtbp3.gif

There are 10 types of people: Those who understand binary, and those who don't.

Appreciate Bacteria! It's the only form of culture some people have.

The brain's right side controls the body's left, so only lefties are in their right mind.

School!

Link to comment
Share on other sites

it dosent matter what the extension is, it just loads the code of each page, and renders it as the extension of the page that both are loading in, give it a try

 

 

 

like, both header and footer are html, but they are put together in the php file, and the variable is set before both template parts are loaded, so the $category is replaced by whatever is is stored in that variable.

Hitman247m.png
Link to comment
Share on other sites

interesting...

 

 

 

so if you knew what you were doing all along, you made this thread because...

 

 

 

the website you used as a reference uses an HTML list, so you're not trying to make that, but rather an include that changes with each page...

 

 

 

if there are any questions you need answered, maybe posting the content of your header would help...

siggyanimatoin5dtbp3.gif

There are 10 types of people: Those who understand binary, and those who don't.

Appreciate Bacteria! It's the only form of culture some people have.

The brain's right side controls the body's left, so only lefties are in their right mind.

School!

Link to comment
Share on other sites

well, what I'm trying to do is make that menu, but rather than manually collapse and expand the menus on each page for the category it is placed in, I can set the category in the php template.

 

 

 

Heres the code for the header:

 

br />
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">









<?php if (defined ('$TITLE')) { print $TITLE; } else { print 'Hitman Central'; } ?>















































				Home

Link

Link

Link

Link

























Category



Home

Link

Link

Link





Category

Category



















Site Stats

					Users Online: <?php include("tools/usersonline.php"); ?>


















Hitman Central 

	> Link









Hitman247m.png
Link to comment
Share on other sites


</pre><ul>

Category



Home

Link

Link

Link





Category

Category

</ul><b

 

it is better to use double quotes (") in html...

 

 

 

create separate variables for each page's links, ie:

 


$home = '          </pre><ul>

Home

Link

Link

Link

</ul>';<b

 

then to check filename:

 


<?php $currentpage = basename($_SERVER['SCRIPT_NAME']);?>

>Category<?php if ($currentpage == 'index.php') {echo $home;}?>

 

the above displays the content of $home if the page is index.php.

 

 

 

hope that helps.

siggyanimatoin5dtbp3.gif

There are 10 types of people: Those who understand binary, and those who don't.

Appreciate Bacteria! It's the only form of culture some people have.

The brain's right side controls the body's left, so only lefties are in their right mind.

School!

Link to comment
Share on other sites

No problem.

 

 

 

 

 

---

 

 

 

 

 

2 ppl, 11 posts...

siggyanimatoin5dtbp3.gif

There are 10 types of people: Those who understand binary, and those who don't.

Appreciate Bacteria! It's the only form of culture some people have.

The brain's right side controls the body's left, so only lefties are in their right mind.

School!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.