PHP HTML CSS Beginner USE CASE / SWITCH / IF ELSE? Need advice...

Posted by WANNABE on Stack Overflow See other posts from Stack Overflow or by WANNABE
Published on 2010-05-27T08:55:17Z Indexed on 2010/05/27 9:11 UTC
Read the original article Hit count: 1207

Filed under:
|

Building a website using a PHP based Ecommerce product Magnto.

The problem I have is that I want to use tabbed navigation.

My idea was to use CSS to show the TAB over the relevant Navigation menu item based on the URL.

However, one URL always changes, so I wanted to somehow use an ifelse statement.

I've come up with two methods that I think could work, could any experts tell me what they would think is best and how they would implement it?

<div id="nav">
<ul id="mainnav">
<li><a href="index.php" title="Welcome page" <?php if ($page == 'index.php') { ?>class="active"<?php } ?>>Welcome</a></li>
<li><a href="about_us.php" title="About us page" <?php if ($page == 'about_us.php') { ?>class="active"<?php } ?>>About us</a></li>
<li><a href="services.php" title="Services page" <?php if ($page == 'services.php') { ?>class="active"<?php } ?>>Services</a></li>
<li><a href="testimonials.php" title="Testimonials page" <?php if ($page == 'testimonials.php') { ?>class="active"<?php } ?>>Testimonials</a></li>
<li><a href="contact_us.php" title="Contact us page" <?php if ($page == 'contact_us.php') { ?>class="active"<?php } ?>>Contact us</a></li>
else
  <li><a href="store.php" title="Store Page" <?php ($page == 'store.php') { ?>class="active"<?php } ?>>Store</a></li>
</ul>
</div>

$URL = store.php; 
SWITCH ($sample) { 
CASE home.php: 
<li><a href="index.php" title="Welcome page" <?php if ($page == 'index.php') { ?>class="active"<?php } ?>>Welcome</a></li>
  break; 
CASE services.php: 
<li><a href="services.php" title="Services page" <?php if ($page == 'services.php') { ?>class="active"<?php } ?>>Services</a></li>
  break; 
CASE aboutus.php: 
<li><a href="about_us.php" title="About us page" <?php if ($page == 'about_us.php') { ?>class="active"<?php } ?>>About us</a></li>
  break; 
DEFAULT: 
<li><a href="store.php" title="Store Page" <?php ($page == 'store.php') { ?>class="active"<?php } ?>>Store</a></li>
}

Thanks in advance

© Stack Overflow or respective owner

Related posts about php

Related posts about beginner