Menu PHP block

This is a simple PHP block taken from the main Template Blocks website. A good feature is that is automatically defines the selected tab based on the URL the visitor is viewing:

<?php
 
$links = array( 'Home' => '/',
                'Features' => '/features.html',
                'Demo' => '/demo.html',
                'Download' => '/download.html',
                'Support' => '/support/',
                'About' => '/about.html'
               );
 
echo '  <ul id="toplinks">';
 
foreach( $links as $key => $value ){
  $selected = ($_SERVER['REQUEST_URI'] == $value) ? ' class="selected"' : '';
  echo '<li><a href="' . $value . '"' . $selected . '><span>' . $key . '</span></a></li>';
}
 
echo '  </ul>';
 
?>

Just replace the array at the top the with your URL list and menu titles. You might also need to make some modifications in the markup that is generated…

2 Responses to “Menu PHP block”

  1. Doone Says:

    hello,

    is it possible to make sub-menus ?

    tank you.

    greedings

  2. admin Says:

    Yes, of course - It’s all up to you, and the sections you create and the admin interface.

    Although (I believe) in the current version only one level of children in supported…

    This is just plain PHP code you can manipulate to show the menu as you want it.

Leave a Reply