SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Jan 2007
    Posts
    86
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Long, long list of files

    Okay, so my Third website is rolling along pretty nicely, but I think I have a craftsmanship question.

    The site consists of a simple header, a menu down the left, of about 30 items (let's call them recipes or catalog pages but they're not), and a text box on the right. Works like a charm. The menus are in PHP includes, because....

    There are a lot of these recipes. I just loaded number 200 into HTML, and I'm just past halfway. I can't have a 400-line menu down the side of the page, so I've divided the items into 30-piece chapters. The user calls Chapter 3; he gets the menu for Chapter 3 (which is in the includes folder) down along the left side of the page, containing links to the designated text items.

    Now, I've got 200 recipe pages in the web page folder. I could see how somebody would say hey, that's too big, it's unprofessional, you gotta set these chapters back in folders and call the pages up outa there. But I can't seem to make PHP do this and I'm not sure that I really need to anyway.

    So: The first question is, is it considered gauche to have a home or root or whatever they call it folder with 400 files in it; and if it is, how do I make PHP call the files out of the folders, with the included menus, and display them? I tried a whole bunch of combinations of folder locations and slashes and no slashes in the links, to no avail so far....

    Thank you for your kind attention.

    Pseu

  2. #2
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    72 Post(s)
    Tagged
    0 Thread(s)
    Well my first response is: It's time to take the step into database usage.

    That way you'd have 1 page for as many recipes as you wanted.

    As far as calling the files from folders, include takes relative pathing.

    PHP Code:
    include('index.php'); //Include index.php from the same directory as this page is running.
    include('folder1/index.php'); //Include index.php from the folder1 directory inside the directory this page is running in.
    include('../header.php'); //Include header.php from the directory above the directory this page is running in. 

  3. #3
    SitePoint Enthusiast
    Join Date
    Jan 2007
    Posts
    86
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah, I should probably do this in a database but I'm not ready for that yet. I want to get a little PHP facility first....
    And I have no idea how to pull a cellful of formatted text out of a database into a div...and using all those keyboard commands to load up the database with 400-something blocks of formatted text...nightmare or just long sessions of work?

    The up-and-down examples that you gave me worked perfectly, though, in a live under-construction part of the site that's just using the dumb bundle of files. Double extra thanks for that!

    Now, I never saw this PHP pathing mentioned anywhere before, especially that two dots thing. What do all those components do, the dots and all?

    More Thanks

    MP

  4. #4
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    72 Post(s)
    Tagged
    0 Thread(s)
    It's actually UNIX style pathing.

    / is used to deliniate directories
    . means "Current Directory"
    .. means "Parent Directory"


    so...
    If i was in /stuff/B/beer/light/index.php
    and I went to find
    ../../../T/tea.jpg

    Means i went up 3 directories (so now i'm at the /stuff/ directory), down one directory into the 'T' directory, and got the 'tea.jpg' file.

  5. #5
    SitePoint Enthusiast
    Join Date
    Jan 2007
    Posts
    86
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Man, you're the best. Thank you.

    P


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
  •