theproximityeffect
theproximityeffect

Reputation: 11

php template engine for existing webpage

I am working with a pretty simple php template right now, stored in one index.php and fetch the files via a GET and access the files like: http://mydomain.com/index.php?page=news if the file is called news.php. See the code snippet below.

 <?
        $fileend = ".php";
        $file="{$_GET["page"]}$fileend";
        $news="news.php";
        if(file_exists($file))
            include($file);
        else
            include($news);
    ?>

Now I want to use a templage engine where I can have different tags for each page, still I don't want to change my file system. Right now my php files looks like this:

<h1>Page Title</h1>
<p>Page Content</p>

I don't use a header as the files are included in my index.php.

I have looked at TinyButStrong and other engines. But I don't know how I should proceed. It should be quite easy. Please let me know how I can do when I don't want to change a lot in my file structure and keep it simple.

Upvotes: 1

Views: 159

Answers (3)

Thomas
Thomas

Reputation: 1

Another template engine what you can use is Separate (see http://separate.esud.info/). It is possible to include files with

<!-- INCLUDE filename --> 

Upvotes: 0

Htbaa
Htbaa

Reputation: 2309

You might give Zend_Layout and Zend_View a try. You don't need to use the MVC part of Zend Framework for this. Biggest plus when using these 2 classes is that templates are simply PHP files. You don't have to use Zend_Layout though, but when working with layouts it does make things easier.

Upvotes: 0

strauberry
strauberry

Reputation: 4199

Try the smarty template engine. It is easy to use and you can use a dedicated template folder. I don't know whether you will have to change a lot because I don't know your file structure ;-)

Upvotes: 1

Related Questions