Jump to content

PHP Template?


chmpdog

Recommended Posts

Hi,

 

Earlier this year I started my website, I thought I didn't need a good template engine, so I made one. Well now I have realized that was a bad Idea. I have run into problems w/ headers and page titles, so now I am looking for an easy template engine to implent in my current system. Heres how my system works, I have all the includes in folder, and then there is a variable to set the page title.

 

Do any of you guys know a template engine that operates like this?

Link to comment
https://forums.phpfreaks.com/topic/147435-php-template/
Share on other sites

Why use a template engine? PHP is it's own template engine.

 

Simple as this:

 

index.tpl.php

<html>
<title><?php echo $title; ?></title>

// display the body items
<!-- include the foot -->
<?php include($_SERVER['DOCUMENT_ROOT'] . '/templates/footer.tpl.php'); ?>
</html>

 

index.php

<?php
//if some condition true
// other processing here also
$title = "Main Index";
include($_SERVER['DOCUMENT_ROOT'] . '/templates/index.tpl.php');
?>

 

No need to go and create a whole new system for something PHP was really designed todo.

Link to comment
https://forums.phpfreaks.com/topic/147435-php-template/#findComment-773832
Share on other sites

yeah .. I think that using template engines is waste of time when you can use the natural PHP templates like premiso suggested. I've also written a short article about it some time ago

http://www.a-scripts.com/general-php/2009/02/23/separate-logic-and-presentation-use-templates/

Link to comment
https://forums.phpfreaks.com/topic/147435-php-template/#findComment-773922
Share on other sites

 

index.tpl.php

<html>
<title><?php echo $title; ?></title>

// display the body items
<!-- include the foot -->
<?php include($_SERVER['DOCUMENT_ROOT'] . '/templates/footer.tpl.php'); ?>
</html>

 

index.php

<?php
//if some condition true
// other processing here also
$title = "Main Index";
include($_SERVER['DOCUMENT_ROOT'] . '/templates/index.tpl.php');
?>

 

Thats what I have, except on my index I have php include another file to get variables for the page title and content. It works if I set my variable on index, but it doesn't if it is set in the other file.

 

Link to comment
https://forums.phpfreaks.com/topic/147435-php-template/#findComment-778668
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.