Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 6 of 6
  1. #1
    Senior Member
    Join Date
    Sep 2003
    Location
    Sydney
    Posts
    114
    Member #
    3051
    So at the moment I'm using if / elseif / else to include my pages so as to only have to update one when the Nav changes etc.

    What I would like to do is to structure my links a little bit better, so it's easier to follow.

    At the moment I have this:

    PHP Code:
    <?php
    if($_GET['id'] == 'destinations') {
    include(
    'destinations.php');
    }
    elseif(
    $_GET['id'] == 'tideas') {
    include(
    'tideas.php');
    }
    elseif(
    $_GET['id'] == 'gday') {
    include(
    'workinghol/gday.php');
    }
        elseif(
    $_GET['id'] == 'flights') {
        include(
    'workinghol/flights.php');
        }
        elseif(
    $_GET['id'] == 'visas') {
        include(
    'workinghol/visas.php');
        }
    elseif(
    $_GET['id'] == 'tpres') {
    include(
    'tpres.php');
    }
    else {
    include(
    'main.php');
    }
    ?>


    You can see that the working holiday/gday section has a few parts to it. I'd like to have it as "index.php?id=gday&subid=flights" etc...just so it's easier to follow.

    Anyone got any tips for this?

    Thanks.

  2.  

  3. #2
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    I'd recommend structuring your site like you're structuring your links. This seems to mostly be the case, except for the gday stuff. Why not just have a [minicode]gday[/minicode] directory with an index.php file that does that [minicode]gday.php[/minicode] does right now, and then have the [minicode]flights.php[/minicode] and [minicode]visas.php[/minicode] files as separate files in that directory? And if you really want to have URIs without `php' in them, go ahead and use [minicode]mod_rewrite[/minicode] to use nicer URIs to point to the same pages.

  4. #3
    Senior Member
    Join Date
    Sep 2003
    Location
    Sydney
    Posts
    114
    Member #
    3051
    Well that's basically how it is...but the main reason for using the includes and stuff is so there's just one page to update the nav and stuff...

  5. #4
    Senior Member
    Join Date
    Sep 2003
    Location
    Sydney
    Posts
    114
    Member #
    3051
    Okay, I got it to work this way. Not sure if it's the best but it works for me...

    Basically I just added the 'work' id which has nothing in it...


    PHP Code:
    <?php
    if($_GET['id'] == 'destinations') {
    include(
    'destinations.php');
    }
    elseif(
    $_GET['id'] == 'tideas') {
    include(
    'tideas.php');
    }
        elseif(
    $_GET['id'] == 'work') {
        }
            if(
    $_GET['subid'] == 'gday') {
            include(
    'workinghol/index.php');
            }
            elseif(
    $_GET['subid'] == 'flights') {
            include(
    'workinghol/flights.php');
            }
            elseif(
    $_GET['subid'] == 'visas') {
            include(
    'workinghol/visas.php');
            }
    elseif(
    $_GET['id'] == 'tpres') {
    include(
    'tpres.php');
    }
    else {
    include(
    'main.php');
    }
    ?>

  6. #5
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    Er... I think your `work' elseif should wrap the if/elseifs inside it. So:

    PHP Code:
    if($_GET['id'] == 'destinations') { 
    include(
    'destinations.php'); 

    elseif(
    $_GET['id'] == 'tideas') { 
    include(
    'tideas.php'); 

    elseif(
    $_GET['id'] == 'work') { 
        if(
    $_GET['subid'] == 'gday') { 
            include(
    'workinghol/index.php'); 
        } 
        elseif(
    $_GET['subid'] == 'flights') { 
            include(
    'workinghol/flights.php'); 
        } 
        elseif(
    $_GET['subid'] == 'visas') { 
            include(
    'workinghol/visas.php'); 
        }

    elseif(
    $_GET['id'] == 'tpres') { 
    include(
    'tpres.php'); 

    else { 
    include(
    'main.php'); 

    That makes sense, though. I usually invert the dependency (every other file includes layout.php, layout.php has the header and footer and such and calls a function, say [minicode]content()[/minicode], which provides the actual content to put in the body), but this is a perfectly valid way to do it.

  7. #6
    Senior Member
    Join Date
    Sep 2003
    Location
    Sydney
    Posts
    114
    Member #
    3051
    Nice one!

    Cheers mate.


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 08:48 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com