Templating a PHP script?

Discussion in 'PHP' started by crazyryan, Mar 1, 2008.

  1. #1
    Hey

    I'm wanting to start working on a PHP script but I'm not sure on the best way of templating it. I was thinking I'd have header.tpl and footer.tpl and then do something like this ...

    
    <?php
    include("includes/config.php");
    include("includes/functions.php");
    include("templates/header.tpl");
    ?>
    
    All of my page content here.
    
    <?php
    include("templates/footer.tpl");
    ?>
    
    PHP:
    Although, the problem with that, is I can't modify page titles and such, unless I do something like, <?php echo $title; ?> in the header.tpl file and then set $title before header.tpl is included.

    Is this an efficient way of doing what I want or is there something better?

    All help is appreciated, thank you.
     
    crazyryan, Mar 1, 2008 IP
  2. swishman

    swishman Well-Known Member

    Messages:
    1,264
    Likes Received:
    28
    Best Answers:
    0
    Trophy Points:
    140
    #2
    i can help you..
    but that will not be free..
     
    swishman, Mar 1, 2008 IP
  3. crazyryan

    crazyryan Well-Known Member

    Messages:
    3,087
    Likes Received:
    165
    Best Answers:
    0
    Trophy Points:
    175
    #3
    Oh damn, I've posted this in the wrong forum.
     
    crazyryan, Mar 1, 2008 IP
  4. milanmk

    milanmk Well-Known Member

    Messages:
    115
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    103
    #4
    milanmk, Mar 1, 2008 IP
  5. swishman

    swishman Well-Known Member

    Messages:
    1,264
    Likes Received:
    28
    Best Answers:
    0
    Trophy Points:
    140
    #5
    lo0ol..i know that bro..
    your problem is very simple..
    a good choice is to use smarty
    but id you want smaller one there are alot
    just search for php template engine
     
    swishman, Mar 1, 2008 IP
  6. crazyryan

    crazyryan Well-Known Member

    Messages:
    3,087
    Likes Received:
    165
    Best Answers:
    0
    Trophy Points:
    175
    #6
    Smarty seems to big for what I want though, I mean, am I going to have problems with my idea or not, because if I don't it's probably going to be best for my fairly small script.
     
    crazyryan, Mar 1, 2008 IP
  7. milanmk

    milanmk Well-Known Member

    Messages:
    115
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    103
    #7
    If its a small script then your approach is absolutely fine.
     
    milanmk, Mar 1, 2008 IP
  8. swishman

    swishman Well-Known Member

    Messages:
    1,264
    Likes Received:
    28
    Best Answers:
    0
    Trophy Points:
    140
    #8
    told u simple..
    go to google.com
    search search for php template engine..
    thats all.
     
    swishman, Mar 1, 2008 IP
  9. Im The ONE

    Im The ONE Peon

    Messages:
    800
    Likes Received:
    40
    Best Answers:
    0
    Trophy Points:
    0
    #9
    A function like
    function header($title) { }
    PHP:
    should do
     
    Im The ONE, Mar 1, 2008 IP