Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.