Jump to content

SugaComa

New Members
  • Posts

    2
  • Joined

  • Last visited

SugaComa's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. @Barand thank you so much, this absolutely worked perfectly with my existing code @ginerjm thank you also, I haven't looked into your answer as yet, but I will as it will help me on my learning journey
  2. Hi All, Im new here, off work with flu and I thought I would try and get some updates done on my website, its been neglected for so long I have a dynamic page listing so I can send my content via a simple template and I use this to then generate the Menu my issue is setting the class "active" I either have none active or all active, I can never seem to get it to pick the currently selected menu item here is a sample of code - if anyone can help me out it would be appreciated. thank you <?php $pageArray = array( 'Page1', 'Page2', 'Page3', 'Page4' ); function active($selected_page){ $menu_array = explode('/', $_SERVER['REQUEST_URI']); $current = end ($menu_array); if ($selected_page == $current); { echo 'active'; } } ?> <ul> <li><a class="<?php active('$pageArray[0]'); ?>" <?php echo 'href="?page=' . $pageArray[0] . '"'; ?>><?php echo $pageArray[0]; ?></a></li> <li><a class="<?php active('$pageArray[1]'); ?>" <?php echo 'href="?page=' . $pageArray[1] . '"'; ?>><?php echo $pageArray[1]; ?></a></li> <li><a class="<?php active('$pageArray[2]'); ?>" <?php echo 'href="?page=' . $pageArray[2] . '"'; ?>><?php echo $pageArray[2]; ?></a></li> <li><a class="<?php active('$pageArray[3]'); ?>" <?php echo 'href="?page=' . $pageArray[3] . '"'; ?>><?php echo $pageArray[3]; ?></a></li> </ul>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.