You are here:  » Top Bar Navigation with Coupon link on Right side.


Top Bar Navigation with Coupon link on Right side.

Submitted by BobL on Mon, 2016-05-09 20:20 in

Hi David,

As I'm sure you are aware, that I have several sub-installs.
I was wondering if it is possible to control the coupon display in the top bar nav, if no coupons were available for that install? Meaning not to show it?
I'm guessing on the order of a if statement?

Bob L.

Submitted by support on Tue, 2016-05-10 08:19

Hello Bob,

Sure - enclose the menu link to your coupon page as follows;

<?php
  $sql = "SELECT id FROM `".$config_databaseTablePrefix."vouchers` LIMIT 1";
  if (database_querySelect($sql,$rows)):
?>
<!-- coupon menu link here -->
<?php
  endif;
?>

Cheers,
David.
--
PriceTapestry.com

Submitted by BobL on Tue, 2016-05-10 12:52

Bob L.

Sweet, Thank you Mr. David.

Got me to what I wanted to do. The above code didn't take into account of expired coupons not being removed.
And what I was trying before kept breaking the top bar.

    <?php
      $now = time();
      $sql = "SELECT id FROM `".$config_databaseTablePrefix."vouchers` WHERE ( (valid_from < '".$now."' AND valid_to = '0') OR (valid_from <= '".$now."' AND valid_to > '".$now."') ) LIMIT 1";
      if (database_querySelect($sql,$rows)):
    ?>
    <ul class='right'>
      <li><a href='<?php print $config_baseHREF."vouchers.php"?>'><?php print translate("Coupons"); ?></a></li>
    </ul>
    <?php
      endif;
    ?>

Works perfect.

Thank you David.
Cheers