Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Need help with php question


mikes

Recommended Posts

I have two navbars, each with a 'more' option. When a user clicks on 'more', I want to toggle between the two. I thought I figured out a slick way... embedding some php code within an '<a href>' tag to toggle a variable and then use that variable to determine which navbar to show. Since the code is embedded within the reference, I don't even have to generate a refresh. My idea worked with one glitch. The variable is not persistant :( I tried setting cookies but I got a message that I couldn't update the headers. I think I'm in past my depth so I was hoping one of you php gurus could help me. Here's the psuedo code (i.e. -- I'm not really using 'var' :) ) of what I've got so far...

 

<a href="go somewhere"
 <? php
 if (var == '1') {
   var = '2';
 } else {
   var = '1';
 }
 ?>
>link text</a>

 

I can 'echo var' afterwards and receive whatever I set var to if it was previously unset, but I can't get var to ever get set to whatever I tell it to if var had been previously set to '1'.

 

Maybe I'm missing something stupid... it has been a long day. But I've tried many permutations, and can't seem to get it to work. Any suggestions would be appreciated!

 

If you are curious, here's the link to the site I'm working on:

 

North West Gift Exchange

Link to comment
Share on other sites

<a href="<?php echo tep_href_link(FILENAME_WHATEVER, tep_get_all_get_params(array('header')) . 'header=' . ( isset($HTTP_GET_VARS['header']) ? (1 - $HTTP_GET_VARS['header'])) : '1'); ?>"><?php echo LINK_TEXT; ?></a>

You also might want to consider using $var instead of var and see if that helps. Note: in the above code, $HTTP_GET_VARS alternates between 0 and 1 rather than 1 and 2. This makes the code easier. Also made a couple changes to fit with osCommerce coding standards.

 

Hth,

Matt

Link to comment
Share on other sites

Actually, that didn't quite do it.

 

I can click on 'more' and it will toggle between the two navbars but if I click on any other option it defaults to the first navbar.

 

What I want is to show navbar1 (called in header.php) on all pages until the user clicks on the 'more' option contained within the navbar. Once they do, I want to show navbar2 on all pages until the user clicks on the 'more' opton located on that navbar.

 

I think what I need is to set a session variable? When a user adds something to their shopping cart without logging in the items are still tracked. However this is done is probably what I want but I don't know how to do it.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...