Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    Regular Coder
    Join Date
    Jun 2007
    Posts
    805
    Thanks
    123
    Thanked 23 Times in 23 Posts

    Best way to load content into website?

    Hi,

    Whenever I've made a website, I've always made the design and general layout at first. Then I've just used that page as a "template" for all future pages on the site. However, I guess that is not the most efficient way to build up a website.

    My site is made up with includes (for the header, footer, etc). But, how would the best way be to load different content whenever a link is clicked? Right now I'm just dublicating the general template and pastes content into the main div - and repeats that behaviour for every single page (gallery, contact, etc).
    Last edited by CaptainB; 04-09-2009 at 07:44 PM.

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,852
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    Senior Coder gnomeontherun's Avatar
    Join Date
    Sep 2007
    Location
    Houston
    Posts
    2,846
    Thanks
    10
    Thanked 238 Times in 229 Posts
    You might consider using a CMS like Joomla! or a template engine like Smarty.
    jeremy - gnomeontherun
    Educated questions often get educated answers, and simple questions often get simple answers.

  • #4
    Regular Coder
    Join Date
    Jun 2007
    Posts
    805
    Thanks
    123
    Thanked 23 Times in 23 Posts
    Hi abduraooft, thanks for the link. I read the thread, however, I'm not totally sure I understand it fully. It seems like the code loads scripts, css, content, etc from a title attribute?

    What I want is just to change the actual content when a link is clicked as every site uses the same css and scripts. I guess there is a simpler way to do this? The solution in the link seems pretty much more advanced than what I need for my little site to me?

  • #5
    Regular Coder
    Join Date
    Jun 2007
    Posts
    805
    Thanks
    123
    Thanked 23 Times in 23 Posts
    Quote Originally Posted by jeremywilken View Post
    You might consider using a CMS like Joomla! or a template engine like Smarty.
    I tend to avoid CMS - I want to code the stuff myself and like to know what every little bit does . Also, I find CMS too feature rich and hard to customize for a little site like mine.

  • #6
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,472
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    Create your content in various plain text files (that can also include some HTML),
    call them .. p1.txt, p2.txt, p3.txt, etc.

    Then at the top of your "index.php", you have something like this:

    <?php
    $page="p1.txt";
    if($_GET['p']){
    $page="p".$_GET['p'].".txt";
    }
    ?>

    Where you want the text (content) to appear, do this:
    <?php include($page);?>

    Now, load various content by specifying the page in a link.

    index.php (if no page specified, p1.txt is loaded as the default).
    index.php?p=2
    index.php?p=3

    Finally, you edit those text files to change content ... either offline,
    or use an online editor such as FCKEditor.

  • Users who have thanked mlseim for this post:

    CaptainB (04-09-2009)

  • #7
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    For a little more security look into using the method described here: http://www.digital-web.com/articles/easypeasy_php_2/
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • Users who have thanked _Aerospace_Eng_ for this post:

    CaptainB (04-09-2009)

  • #8
    Regular Coder
    Join Date
    Jun 2007
    Posts
    805
    Thanks
    123
    Thanked 23 Times in 23 Posts
    Thank you guys, exactly what I was looking for!!


  •  

    Posting Permissions

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