tags:

views:

21

answers:

4

how can i create my own themeing tags/language or whatever its called like shopify is using? smarty has it also, sorry i dont know what its called.

for example in shopify if you type

    <h1> {{ product.title }} </h1> 
- this will print out the products title. what im wondering is how can i create my own language of this type using php?
A: 

It's called a template language. PHP pretty much is a template language, since you can embed PHP code and drop variables into HTML.

People usually have *.tpl files in PHP which they designate as templates, and they're usually kept free of logic-heavy code, so that it looks more like the code you referenced above.

Blaine LaFreniere
A: 

how can i create my own themeing tags/language or whatever its called like shopify is using?

Have a look at:

Sarfraz
A: 

I'm guessing here: being able to call product.title is most likely not a feature of the tempalte engine but of your object model (if any). I guess product.title calls the method / field on the object, which returns the title.

msung
A: 

Shopify's templating engine is called Liquid, and Smarty is itself a templating engine. Use one of these in your app - don't bother implementing your own.

The basic way that they work is you pass them a template file, and a map of variables (such as the "product" variable in your example), and these are exposed as objects you can reference in the template.

Nick