Skip to content
View in the app

A better way to browse. Learn more.

Tip.It Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Help with a php menu system...

Featured Replies

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

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!

  • 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.

Hitman247m.png

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!

  • 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

Hitman247m.png

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!

  • 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.

Hitman247m.png

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!

  • 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









Hitman247m.png


</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!

  • Author

Thanks a lot, exactly what I was looking for :thumbsup:

Hitman247m.png

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!

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.