The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Other Sub Navigation Implementation Approach

  • This topic is empty.
Viewing 1 post (of 1 total)
  • Author
  • #34500

    Currently I have a site that I’m upgrading to use a responsive web design approach. I’m reworking a lot of the HTML and CSS.

    I’m struggling with how to implement the code for the Sub Navigation. I’m using a multi-dimensional array that looks like this:

    $sub_navigation = array(

    'link one' => array(
    'url' => 'link-one/',
    'section' => array( 'Home', 'About' ),
    'priority' => 1,

    // second link

    // third link

    I have a function that quick loops through the $sub_navigation array and adds the links and the markup based on a $section variable. This array is kind of big (via lines of code) and I don’t want to use it in my HTML, i.e.

    I also feel that this is kind of dirty. It’s a little ambiguous to where $sub_navigation variable came from and I just want as little PHP code mixed into my markup as possible.

    I use a header.php that contains the Main and Sub Navigations. I also don’t like the idea of doing this in header.php:

    I could potentially move the sub-navigation.php include to be included right after I include header.php.

    I only have so much time and flexibility to “improve” this so I can’t do anything too radical.

    I am a self taught web developer. Now and then I run into trouble with code/application approaches or design patterns.

    Any and all help and suggestions will be greatly appreciated.

Viewing 1 post (of 1 total)
  • The forum ‘Other’ is closed to new topics and replies.