开发者

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 lo开发者_开发知识库oked 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.


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 ;-)


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.


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

<!-- INCLUDE filename --> 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜