SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Apr 2005
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP includes: 1 file containing many projects, or many files containing 1 project?

    I am currently working on my girlfriend's portfolio site.
    She recently graduated as an interior and furniture designer.

    The site is already online: http://www.evelynejustens.be ,
    but I'm still trying to rationalise it even more.
    This is the first project where I (modestly) use custom written PHP...

    I'm about to implement a very simple separation between content and structure,
    base on this A List Apart article:
    http://www.alistapart.com/articles/phpcms

    This is my question:
    The site is all about displaying projects...
    Is it best to create a separate include file for every project,
    and link to it like this:
    http://www.evelynejustens.be/templat...rojectname.php

    Or is it best to create one include file, that contains all projects,
    and adress them by using a variable, like this:
    http://www.evelynejustens.be/templat...ct=projectname

    I'd like to know which method is preferred in terms of performance, ...

    thanks,

    Johan.

  2. #2
    SitePoint Zealot
    Join Date
    Jun 2007
    Location
    Regina, SK, Canada
    Posts
    129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code PHP:
    <? include("header.php"); ?>
     
    <?
    $proj = $_GET['project'];
    include($proj.'.php');
    ?>
     
    <? include("footer.php"); ?>

    Then you type in template.php?project=stuff or template.php?project=things
    and you would have pages named "stuff.php" or "things.php"

  3. #3
    SitePoint Member
    Join Date
    Apr 2005
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks,

    so you suggest creating a separate PHP file (that will be included) for every project?

    I was hoping to be able to pass a variable:

    Code:
    www.exampleurl.com?variable=project1
    and to use 1 php file, structured like this:

    PHP Code:
    switch ($variable) {
        case 
    "project 1":
            print 
    "project 1 contents";
            break;
        case 
    "project 2":
            print 
    "project 2 contents";
            break;
        case 
    "project 2":
            print 
    "project 2 contents";
            break;

    But maybe this is a performance nightmare??

  4. #4
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    I would have no include files but a templating system that pulls data from a database while using user-friendly urls.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  5. #5
    SitePoint Member
    Join Date
    Apr 2005
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, but why would I use a db?
    It seems like overkill for what I need to get done.
    Besides, I can use SEF URL's by following the include-method, can't I?

  6. #6
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Well, actually, the database is a great way of doing it, because then you can create a custom CMS system to go with it.
    Also, the include idea has so many security issues with it, that you'd need to put alot of validating in to make it hacker safe.
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona


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
  •