Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Header Buttons Or Menu


kwatt

Recommended Posts

Hi folks,

 

I've been banging my head against the wall trying to work out how I would place a small menu or row of buttons on the header. I've worn out several search buttons trying to find an answer to this and to save asking what is, probably, a dumb question to many on here.

 

What I am trying to do is to create a small row of buttons below the "breadcrumb" and "Account/Cart" bar so that people can navigate from the store back to various sections on my main content driven website. So, obviously, all I need to do is create is a small bar there with centralised buttons giving links back to wherever I want them to go.

 

The reason for doing this is that these buttons or text should be seen on ever single page served and they are highly visible.

 

Seems simple enough, but I just cannot seem to work out how to do it. Either I'm being dumb or this is a bit harder than I first thought. :'(

 

Can anyone offer a bit of help and point me in the right direction?

 

K.

Link to comment
Share on other sites

It isn't as difficult as you think. Open your includes/header.php and underneath this code:

 

<table border="0" width="100%" cellspacing="0" cellpadding="1">
 <tr class="headerNavigation">
<td class="headerNavigation">  <?php echo $breadcrumb->trail(' » '); ?></td>
<td align="right" class="headerNavigation"><?php if (tep_session_is_registered('customer_id')) { ?><a href="<?php echo tep_href_link(FILENAME_LOGOFF, '', 'SSL'); ?>" class="headerNavigation"><?php echo HEADER_TITLE_LOGOFF; ?></a>  |  <?php } ?><a href="<?php echo tep_href_link(FILENAME_ACCOUNT, '', 'SSL'); ?>" class="headerNavigation"><?php echo HEADER_TITLE_MY_ACCOUNT; ?></a>  |  <a href="<?php echo tep_href_link(FILENAME_SHOPPING_CART); ?>" class="headerNavigation"><?php echo HEADER_TITLE_CART_CONTENTS; ?></a>  |  <a href="<?php echo tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'); ?>" class="headerNavigation"><?php echo HEADER_TITLE_CHECKOUT; ?></a>   </td>
 </tr>
</table>

 

insert another <table> with your buttons in. Or you could do it with CSS, in a <div>. When you link your buttons, use the osC method so you maintain the session. i.e.

 

<table border="0" width="100%" cellspacing="0" cellpadding="1">
 <tr class="headerNavigation">
<td class="headerNavigation"><?php echo '<a href="' . tep_href_link(FILENAME_DEFAULT) . '">' . tep_image(DIR_WS_IMAGES . 'home.gif', 'Home Page') . '</a>'; ?></td>
 </tr>
</table>

Link to comment
Share on other sites

<?php echo '<a href="' . tep_href_link(FILENAME_DEFAULT) . '">' . tep_image(DIR_WS_IMAGES . 'home.gif', 'Home Page') . '</a>';

 

Thanks Spax. The bit I don't understand is the PHP code and how it works, I am trying to but the stuff I've read so far only seems to cloud the issue, not clarify it for me.

 

I fully understand the idea of tables etc. as they are used in standard HTML, what I can't see in the above statement is how the link, say http:///www.google.com, is made to relate to the image or text used to offer the user the graphical element to actually click on if you see what I mean. Sorry if this appears a stupid question but I'm not familiar with PHP to this extent.

 

To me and, I'm probably wrong, it looks as if the URL would be inserted instead of . tep_href_link(FILENAME_DEFAULT) . but inside the quotes. This would then relate that URL to the image or text before the closing "</a>", is that a correct assumption? Not understanding the function of the "tep" command is probably what's throwing me I suspect.

 

Thanks again for the help.

 

K.

Link to comment
Share on other sites

It does look quite complex...........actually, it is quite complex but only in the way the functions are built.

 

The function tep_href_link does all sorts of wondeful things, like, letting you move between secure and non-secure pages (http and https), determining if you are using search engine friendly urls and it tags on the session id so the user can keep their cart.

 

The tep_image function takes into its parameters, amongst others, options you have configured through your admin. Like the SMALL_IMAGE_WIDTH and HEIGHT.

 

So when you use them together, you call the functions and tell them which parameters you want them to have.

 

<?php echo '<a href="' . tep_href_link(FILENAME_DEFAULT) . '">' . tep_image(DIR_WS_IMAGES . 'home.gif', 'Home Page') . '</a>'; ?>

 

<?php echo says print this code to the browser, until you see ; ?>

 

The PHP Parser will then read the code, make sense of it and output it as HTML and send it to the browser.

 

The tep_href_link function does its thing with the filename you give it in its parameters. FILENAME_DEFAULT which is index.php

 

The tep_image function looks in the images directory DIR_WS_IMAGES for the file named home.gif.

 

Either end of that, you have normal HTML that is directly output as HTML because it is in single quotes '<a href="' and it is all strung together by the full stop characters, which as far as the PHP Parser is concerned, means add together or concatenate.

 

The resulting output is your normal anchor tag:

 

<a href="index.php"><img src="images/home.gif" alt="Home Page"></a>

 

If you are linking to an external page/website, you dont need to use the tep_href_link function. Just use normal anchor tags <a></a>

 

I hope this helps, rather than confuse you.

Link to comment
Share on other sites

Thanks for the patience in helping me get my head around this.

 

Would this be correct within the table as you set out in the example above?

 

<?php echo '<a href="http://www.google.com">Search On Google</a>' . <a href="http://www.yahoo.com">Search On Yahoo</a>; ?>

 

Basically to produce a simply text link to Google's homepage and them on Yahoo as an example.

 

Thanks.

 

K.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...