Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Moving categories to the Header


AndrewRavenwood

Recommended Posts

And today's question is...

 

I have spent almost two hours Googling for this answer, I have also searched this forum of course but I can't seem to find an answer to my problem.

 

Basically I want to move the "Categories" into the header section so that each category becomes a navigation item.

 

I started with this sort of thing - <?php echo include(DIR_WS_BOXES . 'bm_categories.php') ?> - And the answers that I on this forum were along the same lines, but clearly they are for an older version of OSComm and don't work as expected.

 

I also considered moving the right-hand column <div> into the header, which works, but it's a cludge and I hate cludges!

 

As an alternative I could hard code the links but again I see this as a cludge.

 

Module-wise I've found one that uses the method that I initially tried.

 

Any ideas?

Link to comment
Share on other sites

The header and footer module you mentioned just throws the hole box up there which I think you figured out, however there is a Simple Menu Contribution that uses the header / footer modules, it allows you to create a menu that you can style with jquery/superfish, or your own css and stick it in the header or footer. Or you could just create your own using any of your favorite methods spry / jquery and hard code its location into the header. Just make sure you use the correct method for linking so sessions don't get lost...

 

IE

<a href="<?php echo tep_href_link(FILENAME_DEFAULT, 'cPath=31_22'); ?> " title="Category A">Category A</a>

Not

<a href="index.php/&cPath=31_22" title="Category A">Category A</a>

 

Hope that helps

Link to comment
Share on other sites

@@NodsDorf That's definitely a step up from simply hard coding the links, but is far from ideal.

What we need in order to do this is to call whatever method OScomm uses to create a list of valid links. Unfortunately it's so deeply buried within the call to the "boxes" that I personally can't see how to target just the categories.

Link to comment
Share on other sites

@@14steve14 Thanks, using your link I managed to find this gem... http://addons.oscommerce.com/info/8155.

The code that brings in the categories is this if anyone else is interested:-

 

$bm_categories = new bm_categories();

echo $bm_categories->getData();?>

 

After that it's just a simple case of altering the categories.php file to something more semantic and we're in business.

Link to comment
Share on other sites

Since I only wanted to display the top level categories in my navigation bar I decided that I would create my own SQL query and insert it directly into header.php. I hope this will provide an easy cut and paste solution to anyone else wanting the same results.

 

<?

//query top-level navigation items

$navigation= mysql_query("SELECT * FROM categories_description INNER JOIN categories ON categories.categories_id = categories_description.categories_id WHERE categories.parent_id = 0");

?>

<ul>

<li><a class="hidden" href="#skip">Skip menu</a></li><!-- Links to an anchor and exists for reasons of accessibility -->

<?php while($array = mysql_fetch_assoc($navigation)){ ?>

<li>

<a href=<?php echo tep_href_link(FILENAME_DEFAULT, "cPath/".$array['categories_id']); ?> ""><?php echo $array['categories_name']; ?></a>

</li>

<?php } ?>

</ul>

 

I did intend to add this as a contribution but my login and password aren't recognised by the Add-on part of the site so this will have to do :)

Link to comment
Share on other sites

  • 1 month later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...