SitePoint Sponsor

User Tag List

Results 1 to 18 of 18
  1. #1
    SitePoint Zealot MarshallX's Avatar
    Join Date
    Jun 2002
    Location
    Essex, Ontario
    Posts
    101
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    index.html?Pageid=news

    Hey guys, continuing with my page here, has there been a post or a tutorial somewhere on how to setup your pgae navigation like this:

    www.test.com/index.html?p=news

    I'm sure its not that advanced, but I would like to learn how to do it.

  2. #2
    SitePoint Zealot MarshallX's Avatar
    Join Date
    Jun 2002
    Location
    Essex, Ontario
    Posts
    101
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just to add....will this make it so I only have to do the navigation bar etc on index.html, so when I have to change a link, I dont have to do it 20 times?
    Team Sportscast Network
    2D / Graphics Designer
    MSN / Email : joshvermast@hotmail.com

  3. #3
    $postcount++; koomann's Avatar
    Join Date
    Feb 2003
    Location
    Posts
    428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Wouldn't it be index.php...? I'm not sure.

    But anyways, I was wondering how to do the same. :\

  4. #4
    Can we go to a 48 hour day?
    Join Date
    May 2002
    Location
    MI
    Posts
    906
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think what you are looking for are includes, not calling all content from a single page. That allows you to include a nav bar on every page with only one file to edit. This is something I started working on about this. Check it out and see if this helps.
    http://www.ricksweb.info/php/tutorials.php?ID=1
    mitechie.com
    "Techies just think a little differently
    ...at least that is what they keep telling me."

  5. #5
    SitePoint Zealot MarshallX's Avatar
    Join Date
    Jun 2002
    Location
    Essex, Ontario
    Posts
    101
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hrm...that just explains includes, don't think its what I am looking for. See how on your page it says ID=1, i need to do that ie. ID=news.
    Team Sportscast Network
    2D / Graphics Designer
    MSN / Email : joshvermast@hotmail.com

  6. #6
    Apache Expert i_like_php's Avatar
    Join Date
    Nov 2001
    Location
    Dallas, Texas
    Posts
    1,342
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it's done by using a database
    i love php

  7. #7
    SitePoint Wizard
    Join Date
    Oct 2001
    Location
    Tucson, Arizona
    Posts
    1,858
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by i_like_php
    it's done by using a database [img]images/smilies/smile.gif[/img]
    Not necessarily. Check out this code:
    PHP Code:
    <?php

    $this_page 
    explode('/'$_SERVER['PHP_SELF']);
    $this_page $this_page[count($this_page)-1];
    $request $_GET['p'].'.php';

    if (
    file_exists($request) && $this_page != $request)
    {
        include 
    $request;
    }
    else
    {
        echo 
    'There was a problem with your previous action...';
    }

    ?>
    You can save this code as index.php and then call any page you want by using index.php?p=news (assuming that a news.php file exists). [img]images/smilies/smile.gif[/img]

  8. #8
    SitePoint Zealot MarshallX's Avatar
    Join Date
    Jun 2002
    Location
    Essex, Ontario
    Posts
    101
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well say they goto index.php?p=media

    I need it to goto the media page, then they goto index.php?p=pictures and it goes to the picture page, get my drift?
    Team Sportscast Network
    2D / Graphics Designer
    MSN / Email : joshvermast@hotmail.com

  9. #9
    SitePoint Wizard
    Join Date
    Oct 2001
    Location
    Tucson, Arizona
    Posts
    1,858
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by MarshallX
    Well say they goto index.php?p=media

    I need it to goto the media page, then they goto index.php?p=pictures and it goes to the picture page, get my drift?
    Umm, spot-on. [img]images/smilies/smile.gif[/img] That's what my code sample does for you. You could (and you'll probably want to) extend the snippet by including a header and footer, and voila--you've got a barebones templating system.

  10. #10
    $postcount++; koomann's Avatar
    Join Date
    Feb 2003
    Location
    Posts
    428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by mattjacob
    Not necessarily. Check out this code:
    PHP Code:
    <?php

    $this_page 
    explode('/'$_SERVER['PHP_SELF']);
    $this_page $this_page[count($this_page)-1];
    $request $_GET['p'].'.php';

    if (
    file_exists($request) && $this_page != $request)
    {
        include 
    $request;
    }
    else
    {
        echo 
    'There was a problem with your previous action...';
    }

    ?>
    You can save this code as index.php and then call any page you want by using index.php?p=news (assuming that a news.php file exists). [img]images/smilies/smile.gif[/img]
    Just making sure....
    So, any page could be called upon just by the URL: site.com/index.php?p=page.php?

  11. #11
    SitePoint Wizard
    Join Date
    Oct 2001
    Location
    Tucson, Arizona
    Posts
    1,858
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by koomann
    Just making sure....
    So, any page could be called upon just by the URL: site.com/index.php?p=page.php?
    Nope. The query string would look like http://www.yoursite.com/index.php?p=photos, where the file photos.php already exists in your root directory. To call files in other directories, use something like http://www.yoursite.com/index.php?p=foo/bar/pepsi, where pepsi.php exists in /foo/bar on your server. Sorry for the Pepsi example, but I've got a can of it sitting here in front of me.

  12. #12
    $postcount++; koomann's Avatar
    Join Date
    Feb 2003
    Location
    Posts
    428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks matt.
    But what exactly would something like this be used for?

  13. #13
    SitePoint Wizard
    Join Date
    Oct 2001
    Location
    Tucson, Arizona
    Posts
    1,858
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's really just to make things simpler on you. You would probably include a header file that has your navigation in it and also a footer with copyright information or whatever. Then you could update those two files and changes would be reflected across your entire site.

  14. #14
    Apache Expert i_like_php's Avatar
    Join Date
    Nov 2001
    Location
    Dallas, Texas
    Posts
    1,342
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by mattjacob
    Not necessarily. Check out this code:
    PHP Code:
    <?php

    $this_page 
    explode('/'$_SERVER['PHP_SELF']);
    $this_page $this_page[count($this_page)-1];
    $request $_GET['p'].'.php';

    if (
    file_exists($request) && $this_page != $request)
    {
    include 
    $request;
    }
    else
    {
    echo 
    'There was a problem with your previous action...';
    }

    ?>
    You can save this code as index.php and then call any page you want by using index.php?p=news (assuming that a news.php file exists). [img]images/smilies/smile.gif[/img]
    so are you saying i can use this code instead of using a database to get the same results?

    also does this page name need to be named index.php or can you name it whatever you want?
    i love php

  15. #15
    SitePoint Zealot MarshallX's Avatar
    Join Date
    Jun 2002
    Location
    Essex, Ontario
    Posts
    101
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, to suit my needs, all I did was where the table that I needed my content was I put:
    <?php if($page=="news") include("gennews.php")?>
    etc, for each page. Works fine!
    Team Sportscast Network
    2D / Graphics Designer
    MSN / Email : joshvermast@hotmail.com

  16. #16
    $postcount++; koomann's Avatar
    Join Date
    Feb 2003
    Location
    Posts
    428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hm, nifty little idea there Marshall...I'll be using this sooner or later

  17. #17
    SitePoint Wizard
    Join Date
    Oct 2001
    Location
    Tucson, Arizona
    Posts
    1,858
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by MarshallX
    Well, to suit my needs, all I did was where the table that I needed my content was I put:
    <?php if($page=="news") include("gennews.php")?>
    etc, for each page. Works fine!
    Oy vey.

  18. #18
    SitePoint Wizard
    Join Date
    Oct 2001
    Location
    Tucson, Arizona
    Posts
    1,858
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by i_like_php
    so are you saying i can use this code instead of using a database to get the same results?
    Not really. Call it a poor man's database.

    Quote Originally Posted by i_like_php
    also does this page name need to be named index.php or can you name it whatever you want?
    You can call it whatever you want. Some suggestions: template.php, yoursitename.php, loader.php, whatever.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •