PHP TEMPLATES

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply

What is a tpl

Poll ended at Sat May 28, 2005 6:33 am

template
7
78%
not template
2
22%
 
Total votes: 9

shehran
Forum Newbie
Posts: 1
Joined: Fri May 27, 2005 6:20 am
Contact:

PHP TEMPLATES

Post by shehran »

CAN any one tell me how .tpl works with php, its a real confuing topic. :(
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

.tpl is, for me, parts of a template system. The tpl extension is really nothing, but was born (or became most famous) during the creation of Smarty.

If you visit the Smarty homepage and browse around for a while, you'll likely get abit more understanding of it's use.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

I think generally it's just a file extension people put on template files. .html, .inc, .php, .yourneighborsdog would also work, .tpl is just for humans to look at the file and know what it is.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Sphen001
Forum Contributor
Posts: 107
Joined: Thu Mar 10, 2005 12:24 pm
Location: Land of the Beaver

Post by Sphen001 »

Just to note however, is that some editors (ie, Dreamweaver) don't recognize the .tpl extension, so some software (ie, phpBB) have switched back to .html extensions. In the end though, it doesn't really matter. It's just a way of distinguishing templates from other files.

Sphen001
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

The thing I don't like about .tpl files (at least in so far as phpBB is concerned) is taht you can't include any php scripts in them (by default...I know you can tweak stuff to make it work, but that's more work 8O ).

Look at some other systems that use "themes" like atutor that use just .php files for the template files...you can do whatever you wnat (php-wise) in them which, to me, is a life saver.

I think the .tpl is good for a convention, but that's it. If you put all of your template files in a folder called "templates" or some such and then break down the different themes into subs, you're gonna know what you're dealing with w/o having to look at the file extension.
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post by McGruff »

You could add two extensions: "foo.tpl.php"
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

.tpl files are the "presentation" portion of your application when you split your applications into "code" and "presentation". These files are usually part of a parsing application (like Smarty or FasTemplates(?)) that are brought into your application just before output to the browser. Generally they have a variable assignment convention like {VAR_NAME} or [%VAR_NAME%] where the templated variable is replaced with the assigned variable from your PHP code. This is done to prevent writing "spaghetti code" where your code and HTML are intertwined and are harder than heck to modify later.

Sometimes developers use other extensions to name template files, such as .inc, .html, .temp, .inc.html, etc. Just make sure you understand that by themselves .tpl files, like .inc files, don't do anything. They are just used as a means to clean up application code by separating code and presentation.

On a side note, I am just about out of quotations marks. Does anyone have any I can "borrow"?
User avatar
neophyte
DevNet Resident
Posts: 1537
Joined: Tue Jan 20, 2004 4:58 pm
Location: Minnesota

Post by neophyte »

I name all my template files for Smarty/phpbb/Yapter .html. Why because Dreamweaver and other html editors recognize it. Yeah and my Mac OS X thinks .tpl files are Photoshop Duotone files and so any .tpl that lands in my mac file system is instantly converted to it. There's a lot of things I like about Mac OS X but I could do with out their file/extension management system. So for those reasons I keep the .html extension. There are plenty of projects that don't use templates. It's all personal preference...
Post Reply