CMS Template Engine
Moderator: General Moderators
CMS Template Engine
Hello PHPDN,
I'm currenlty working with a client and he wants a control panel to manage his layouts. Well there is a problem in what he wants. He wants a CMS that can work with any layout he designs. Well I want to make my own "template" engine sort of like the Smarty engine where he can do {$TITLE_HERE} and I was wondering where I should start? I'm going through the Smarty engine now and the PHPBB template engine but I was wondering if there is some type of tutorial on making your own Smarty-like engine. Thanks
I'm currenlty working with a client and he wants a control panel to manage his layouts. Well there is a problem in what he wants. He wants a CMS that can work with any layout he designs. Well I want to make my own "template" engine sort of like the Smarty engine where he can do {$TITLE_HERE} and I was wondering where I should start? I'm going through the Smarty engine now and the PHPBB template engine but I was wondering if there is some type of tutorial on making your own Smarty-like engine. Thanks
- MrPotatoes
- Forum Regular
- Posts: 617
- Joined: Wed May 24, 2006 6:42 am
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
GPL in no way limits your ability to sell your software -- it may make some requirements that you include the source with your product, but since you got that code for free you should anyway.MrPotatoes wrote:i either need a licence where ic an sell my software of make my own. and seeing the over abundance of GPL and GNU style licences i'm gonna hafta make my own
(#10850)
- daedalus__
- DevNet Resident
- Posts: 1925
- Joined: Thu Feb 09, 2006 4:52 pm
A dynamic title, like in the title bar? Or are you trying to figure out how to output a variable to the page?
Note: .htm and .html files won't get parsed by php by default, the files have to be named .php
??
Note: .htm and .html files won't get parsed by php by default, the files have to be named .php
Code: Select all
$page_title = "Welcome to my site?";
echo $page_title;No I understand how to varibles.
, I'm wanting to make a script that took {$SITE_TITLE} out of a html or lets say .tpl files in my /themes/ folder and the PHP script read it and inserted the data from the varible $SITE_TITLE. Basicly I'm not sure if you have ever used PHPBB but when making a theme they allow the theme designers to use {$VARIBLES} into there .tpl files. My PHP script is going to take there .tpl files and generate the page. So basicly I could use multiple themes with the same PHP script and it doesn't take another PHP coder to make layouts for it. aka like the Smarty engine.
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
There are several common ways to do templates in PHP:
1. Use embeded <?php ?> tags and include the template. The result can be captured with output buffering if desired.
2. Load the template into a string and have the variables in the template expanded by PHP string parsing capabilities.
3. Use str_replace()/preg_replace()/etc. to replace tags within a template loaded as a string.
4. XML/XSL/XLST translation.
For #1 and #2 you might want to check into the expand() function.
1. Use embeded <?php ?> tags and include the template. The result can be captured with output buffering if desired.
2. Load the template into a string and have the variables in the template expanded by PHP string parsing capabilities.
3. Use str_replace()/preg_replace()/etc. to replace tags within a template loaded as a string.
4. XML/XSL/XLST translation.
For #1 and #2 you might want to check into the expand() function.
(#10850)
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Why not just use the phpbb template.php code?William wrote:No I understand how to varibles., I'm wanting to make a script that took {$SITE_TITLE} out of a html or lets say .tpl files in my /themes/ folder and the PHP script read it and inserted the data from the varible $SITE_TITLE. Basicly I'm not sure if you have ever used PHPBB but when making a theme they allow the theme designers to use {$VARIBLES} into there .tpl files. My PHP script is going to take there .tpl files and generate the page. So basicly I could use multiple themes with the same PHP script and it doesn't take another PHP coder to make layouts for it. aka like the Smarty engine.
expand() function?arborint wrote:There are several common ways to do templates in PHP:
1. Use embeded <?php ?> tags and include the template. The result can be captured with output buffering if desired.
2. Load the template into a string and have the variables in the template expanded by PHP string parsing capabilities.
3. Use str_replace()/preg_replace()/etc. to replace tags within a template loaded as a string.
4. XML/XSL/XLST translation.
For #1 and #2 you might want to check into the expand() function.
- MrPotatoes
- Forum Regular
- Posts: 617
- Joined: Wed May 24, 2006 6:42 am
yeah, your right, but if i want to keep something closed source then i can't do it under GPL. i guess i should have wrote that betterarborint wrote:GPL in no way limits your ability to sell your software -- it may make some requirements that you include the source with your product, but since you got that code for free you should anyway.MrPotatoes wrote:i either need a licence where ic an sell my software of make my own. and seeing the over abundance of GPL and GNU style licences i'm gonna hafta make my own