Hitman247m Posted August 21, 2007 Share Posted August 21, 2007 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: 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: Link to comment Share on other sites More sharing options...
r2d2 Posted August 21, 2007 Share Posted August 21, 2007 php? it can be done with javascript. in the : then in the : 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 More sharing options...
Hitman247m Posted August 21, 2007 Author Share Posted August 21, 2007 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. Link to comment Share on other sites More sharing options...
r2d2 Posted August 21, 2007 Share Posted August 21, 2007 your code doesn't have a menu at all, unless it is in header or footer.html, but then $category wouldn't help you... 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 More sharing options...
Hitman247m Posted August 21, 2007 Author Share Posted August 21, 2007 Yes, I know... the menu would be in the header, with a variable in its code, so I can set that number independantly with each page Link to comment Share on other sites More sharing options...
r2d2 Posted August 21, 2007 Share Posted August 21, 2007 you can't have php in .html files... 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 More sharing options...
Hitman247m Posted August 22, 2007 Author Share Posted August 22, 2007 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. Link to comment Share on other sites More sharing options...
r2d2 Posted August 22, 2007 Share Posted August 22, 2007 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... 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 More sharing options...
Hitman247m Posted August 22, 2007 Author Share Posted August 22, 2007 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 Link to comment Share on other sites More sharing options...
r2d2 Posted August 23, 2007 Share Posted August 23, 2007 </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. 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 More sharing options...
Hitman247m Posted August 23, 2007 Author Share Posted August 23, 2007 Thanks a lot, exactly what I was looking for :thumbsup: Link to comment Share on other sites More sharing options...
r2d2 Posted August 23, 2007 Share Posted August 23, 2007 No problem. --- 2 ppl, 11 posts... 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now