Revisiting Drop Down Menus, Sitemaps & PHP Includes

More about Sitemaps

It is a good practice to refer to URLs in your sitemap as root relative or absolute, so that the sitemap can be included in files that are in all folders and subfolders of the site.

Search engines love to use sitemaps to crawl a site – they prefer an XML-based sitemap file with absolute URL references to each page to be indexed on the site.    There are many tools that will help you set this up, such as this free XML Sitemap Generator.  There are even tools such as Google XML Sitemap Generator for keeping XML sitemaps of WordPress blogs.  Once you create your XML sitemap, you can register the site and the sitemap with Google Webmaster Tools and Bing Webmaster Tools.

More about Server-side includes

In Project 2 we saw how server-side includes can make a dynamic website by using them with conditional PHP statements to build customized pages.  Now in Project 3, we have seen  how server-side includes, implemented very simply with one line of PHP, can make managing a large website so much simpler by centralizing the sitemap in one place on the server – for all navigation elements on all pages.

There are many other applications where a very simple use of PHP server-side includes can make a web developer several magnitudes more productive or capable.    One other example is this MetaTitle include script – a simple script for consolidating into one file the meta-data and page title information for each page on a website.  This simple script requires that each page have a unique file name.    Unzip the folder and test it out, it should be pretty straightforward to implement.

There are several  interesting programming features used in this script:

Superfish Menu

I redid the White House menu using the Superfish menu based on JQuery.   I thought that maybe using jquery would make it easier to implement the dual menu approach, by using the nav in the selector of the superfish instantiator:
jQuery(function(){
jQuery('nav ul.sf-menu').superfish();
});

This did not work – the stylesheet needed to be modify similar to the Leigber example by specifying all the rules with the nav and footer modifiers.

Having implemented the complex White House sitemap using  Superfish, Leigber and SPRY Menu widget, I found  Leigber to be the simplest, lightest-weight and most attractive solution.    However, given the extremely long list of issues that this country faces, the whitehouse.gov custom 3 column menu is by far the best solution for the website.

2 comments for “Revisiting Drop Down Menus, Sitemaps & PHP Includes

  1. Tom Chadsey
    February 21, 2011 at 2:05 pm

    Explode seems like the long way to get the filename

    Is the basename function reliable?

    $basename = basename($_SERVER['REQUEST_URI']);
    or
    $basename2 = basename($_SERVER['PHP_SELF']);

  2. February 21, 2011 at 6:12 pm

    Yes, that is true, basename() has been in PHP as long as explode() has and would be a little more straightforward.

    However, explode() is a good function to know about, there are many ways it can be used for other applications, and in this case it provides the complete folder hierarchy, which could be useful for expanding this metatitle utility with additional features.

Comments are closed.