Zen Cart Logo
Forums / General Questions / PHP help needed: including a master navigation menu

PHP help needed: including a master navigation menu

Views: 609

Results 1 to 5 of 5
12 Jun 2012, 5:33 AM
#1
ideashop avatar

ideashop

New Zenner

Join Date:
Sep 2007
Posts:
24
Plugin Contributions:
0

PHP help needed: including a master navigation menu

I have a client who runs multiple websites, and wants a common navigation menu on each of the sites. To make the menu work, I need to include a CSS and an HTML file. On the other 2 websites, I do it like so:

(In the header)
<link href="/CSS/menustyle.css" rel="stylesheet" type="text/css" media="all" />

(In the body)
<!--#include virtual="/Includes/navbar.html" -->

I can't for the life of me figure out how to do this in the PHP code for Zencart. I have figured out the location where I want to include the navbar.html file in the tpl_header.php file. However, I don't know how to write a simple include statement that shows where to look for the correct file. The menu can be displayed on every page, so it doesn't need to have if/then functionality.

I'm sure this is really simple, but I've been trying to figure out how to do this for over an hour now. :frusty:

TIA for the help!

12 Jun 2012, 7:18 AM
#2
balihr avatar

balihr

Totally Zenned

Join Date:
Oct 2008
Location:
Croatia
Posts:
1,784
Plugin Contributions:
21

Re: PHP help needed: including a master navigation menu

I'd say the most "Zen" way would be to do the following:

  1. create a file called tpl_header_menu.php and add all the content from your navbar.html to that file.
  2. upload that file to your includes/templates/YOUR_TEMPLATE/templates/ directory
  3. add the following line to your includes/templates/YOUR_TEMPLATE/common/tpl_header.php: ```
<?php require($template->get_template_dir('tpl_header_menu.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_header_menu.php'); ?>
4. put your menustyle.css in your includes/templates/YOUR_TEMPLATE/css/ directory and rename it to stylesheet_menustyle.css

That's it. :smile:
13 Jun 2012, 6:26 AM
#3
ideashop avatar

ideashop

New Zenner

Join Date:
Sep 2007
Posts:
24
Plugin Contributions:
0

Re: PHP help needed: including a master navigation menu

Cool, I'll give it a try. Thanks very much! Do I need to add a line to have the CSS included or is it automatic?

13 Jun 2012, 7:38 AM
#4
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: PHP help needed: including a master navigation menu

Add your CSS file into your /includes/templates/NAME_OF_YOUR_TEMPLATE_HERE/css/ folder ... and rename it so that it starts with "style" and ends in ".css"

ie:
/includes/templates/NAME_OF_YOUR_CUSTOM_TEMPLATE_FOLDER/css/styles_for_nav.css

Described here:
http://www.zen-cart.com/wiki/index.php/Customisation_-_Templates_-_Stylesheets_-_Per-Page-Rules

19 Jun 2012, 3:25 AM
#5
ideashop avatar

ideashop

New Zenner

Join Date:
Sep 2007
Posts:
24
Plugin Contributions:
0

Re: PHP help needed: including a master navigation menu

Thank you both. I now have my dropdown menu working smoothly. :smile: