Forums

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

Home Forums Back End PHP for Navigation?…

  • This topic is empty.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #27287
    WildSpirit
    Member

    I am working on a website that has over 100 pages. There have been a couple changes already to the navigation and I potentially see more coming…

    Would be using PHP (something I have NO CLUE about) be worth looking into?

    Going through each page to make a navigational correction is time consuming and tedious!!

    I’m open to any ideas!

    Thanks,
    Lyle

    #68448
    TheDoc
    Member

    Certainly! I almost always use a PHP include for the header/nav on static sites. It could be something as simple as:

    The PHP: (I always keep all of my includes in a folder called "includes", but that’s a personal preference)

    Code:

    and then in the nav.html file:

    #68449
    TheDoc
    Member

    Also, remember for PHP to function properly, the page name will have to be .php, not .html.

    #68459
    WildSpirit
    Member

    OK I have no knowledge of PHP can you recommend a tutorial for this??…

    I’m searching for stuff now but on the flip side I’m not a 100% positive what I’m looking for. Kindda like a catch22!

    Thanks,
    Lyle

    #68463
    TheDoc
    Member

    Here’s a reeeeaaaaally simple demo:

    This is your index.php page:

    Code:




    This is a Sample!

    Hi, I’m content


    And in a file located in a folder called "includes", your navigation.html file:

    It’s as simple as replacing everywhere your navigation is with this line:
    <?php include(‘includes/navigation.html’); ?>

    Then you only have to update one file (navigation.html) whenever you want to make a change to it.

    #68489
    WildSpirit
    Member

    WOW that sounds more simple! That would make my life easier too!!

    One more question: If using CSS to style my nav. how does that get worked in?

    Going off the code below could I add a div with ID of nav around the php and that would add apply my styles?

    <div id="header">
    <h1>Sample</h1>
    </div><!–close header–>

    <div id="nav">
    <?php include(‘includes/navigation.html’); ?>
    </div>

    OR does my CSS need to use the ID of "mainnav"?

    I hope this is making sense!

    Thanks,
    Lyle

    #68491
    TheDoc
    Member

    I just put in "mainnav" because that’s what I usually call it.

    Also, you DON’T need to wrap the <ul> in a <div>.

    You can style the <ul> just like you would a <div>.

Viewing 7 posts - 1 through 7 (of 7 total)
  • The forum ‘Back End’ is closed to new topics and replies.