August 21, 200718 yr 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:
August 21, 200718 yr 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!
August 21, 200718 yr Author 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.
August 21, 200718 yr 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!
August 21, 200718 yr Author 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
August 21, 200718 yr 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!
August 22, 200718 yr Author 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.
August 22, 200718 yr 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!
August 22, 200718 yr Author 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
August 23, 200718 yr </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!
August 23, 200718 yr 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!
Create an account or sign in to comment