treehouse : what would you like to learn today?
Web Design Web Development iOS Development

PHP Article Template

  • Anyone have a template of a static page design in PHP were certain divs get thier data from a variable given by the user?
    Get it? :/ No WP!
  • I'm trying to create an article system without any Wordpress or that kind of stuff but I really just don't know where to begin. I'm thinking like, in the document the user sees there's this code:
    <!doctype html>
    <html>
    <head>
    <title>iP5T - <?php echo $aH ?></title>
    <link rel="stylesheet" href="css/page.css">
    </head>
    <body>
    <div id="content">
    <header class="articleHeader">
    <h1>iPhone 5 Thoughts</h1>
    </header>
    <section>
    <h2><?php echo $aH ?> - <?php echo $aW ?></h2>
    <article>
    <p><?php echo $aC ?></p>
    </article>
    </section>
    </div>
    </body>
    </html>

    But the thing is, how do I make these articles and actually send them into this template which then creates a file with the specific data?

    Please help..
  • Help please? :(
  • Seriously, anyone?? Either no one has seen this post or you don't understand my question.. :/
  • I'm not that knowledgeable in PHP but it sounds to me like you'd be creating a ton of variables to echo out each article.
  • Well that doesn't really help me.. But I guess you're quite right.
  • Although it may not be ideal, you could just use Wordpress for a blog only and have the rest of your site the way it is now.
  • I know, except that I really want to try this by my own. I actually think it's quite easy the way I'm thinking of it, just that I don't really know HOW to write it in PHP.
  • It sounds easy but it doesn't seem to be. How are you going to get different articles with the same "$aC" variable? The way I see it you would have to create a different one for each article.
  • If there isn't too much content:

    In your database create a "content" table (call it what you like) with columns for id (name/number reference) and then each bit of data -- title, subtitle, content, etc. User input (GET request?) should be sanity checked and then used to retrieve the relevant items as variables.

    You can then develop a separate interface for adding articles.

    For a more comprehensive look at a PHP design that does what you are describing, look at the source code for Kroc Camen's site, camendesign.com.

    http://camendesign.com/.system/
  • Well, I'm thinking like that every article has it's own page 'article-title.php' and on the front page there's just a couple iframes? Simple as that, that database suggestion is good.