Looking For Exmples

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
JakeJ
Forum Regular
Posts: 675
Joined: Thu Dec 10, 2009 6:27 pm

Looking For Exmples

Post by JakeJ »

I'm building a header page and all of my content is coming from include files.

Does anyone have some good examples of building navigation from include files? There will be different navigation buttons for the side bar as well as a menu across the top. But just having one or the other would be great and I can adapt from there.

Feel free to either post code and/or attach files.

Thanks!
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Looking For Exmples

Post by requinix »

For simple stuff I have two functions: one for outputting the header, one for outputting the footer. The two functions take arguments and decide what to do from there.

Like

Code: Select all

<?php // include file

function page_header($title, $nav1, $nav2) {
    // echo the HTML that appears before the content
    // use $nav1 and $nav2 to decide what buttons should be marked as active/currently being visited
}

function page_footer() {
    // echo the HTML that appears after the content
}

Code: Select all

<?php

include "include file";

page_header("Page title", "First", "Second");

// print page content

page_footer();
There are a billion ways to do this. Come up with something that seems simple and logical to you.
JakeJ
Forum Regular
Posts: 675
Joined: Thu Dec 10, 2009 6:27 pm

Re: Looking For Exmples

Post by JakeJ »

Thanks,

And I know there's a billion ways, I'm just looking for some examples so I can get an idea of what's going to work best for me since I haven't had the need to do this.

Keep the examples coming!
Post Reply