Jump to content

How To Change Style Of Nav Menu On Ecom Tut


Recommended Posts

Because the ecommerce script is so simplified and efficient, I can't figure which and where data is being get and set from in order to style the navigation menu - such as adding a drop down menu item.





<ul class="products">
        <?php $this->get_data('products'); ?> <!-- this data will hold all the data: product, image, price, add to cart button -->
This piece of scripts gets data from the m_categories.php which is also very OOP that I can't figure out where the html starts and finishes.
Any ideas on where to start looking in order to add a drop down menu??
Thanks in advance ;)
Link to comment
Share on other sites

You'd need to start in the view and work backwards. In this case, the code you included is actually the code to list the products, not the navigation. The navigation is in the header file (app/views/includes/public_header.php ), since it's a global item that appears on all pages. Here's the correct code:


<ul class="nav">
<?php $this->get_data('page_nav'); ?>
So the next step would be to check the controller, and see where set_data('page_nav') is set. In the index file, look for the "$Template->set_data('page_nav', )" line: it should be on lines 17 and 44 (or very close). Here's the code for one of those sections:
// get category nav
$category_nav = $Categories->create_category_nav($category['name']);
$Template->set_data('page_nav', $category_nav);
So the navigation is created by the $Categories object's "create_category_nav" method, which accepts the argument of the currently active navigation item (in the index.php file, either that's the home page, or the name of the currently active category.)


In order to change this, you'd need to modify the code to call set_data('page_nav') with your own navigation content. If the navigation will stay basically the same, with categories being the main focus, I would find and edit the "create_category_nav" method in the m_categories.php code. If not, perhaps you should create a new method within the main template file (m_template.php) that will return the HTML needed to create the navigation. Once you have it working on the home page, then apply that same change to any other controllers that need the updated navigation.


If you want a dropdown, you'll likely need to modify the HTML, as well as add any CSS/Javascript that you will need. Does that help at all?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...