lmgtfy.com -- That's a nifty little site.
I did Google the topic before asking the question earlier. It seems that SMARTY is the most widely used templating engine in use. There isn't much information on "native" PHP templating. A couple things I found was very lite in terms of information.
So if anyone knows of a book or website that is useful on this topic please share with me.
Thanks..
I did Google the topic before asking the question earlier. It seems that SMARTY is the most widely used templating engine in use. There isn't much information on "native" PHP templating. A couple things I found was very lite in terms of information.
So if anyone knows of a book or website that is useful on this topic please share with me.
Thanks..
smarty isn't that widely used. It's just the only "branded" template system. You know it only as a popular "buzz" word. But as with most hyped-up designs.. eventually they cool off and people realize its shortcomings.
In the case of smarty.. well I can't really understand it.
Normal php:
Smarty:
There is actually MORE typing there, and it doesn't look any cleaner to me. And you still need to learn smarty language. You are better off learning php as its globally used and even works on smarty pages. It's universal.
Its not called "native templating".. its not called anything.. its like drinking water from a glass.. its just what you do. php is an embeddable language. Much like javascript. But php gets translated before the web server loads the page, javascript is done on the clients browser.
You set variables in the controller files that are used in the view files. If you want to show the product name for example. You do a database query in the controller for that product, and then set the name value to a variable that the view will use. The view is simple html. You can make tables and divs and images like any other static webpage. The only difference is that for displaying the variable that you set, you simply enclose the variable in tags <?php and ?>.
So if the variable set is $product_name then in the html file you would type
<?php echo $product_name; ?>
In the case of smarty.. well I can't really understand it.
Normal php:
Code: Select all
<? foreach ($myArray as $foo)?>
<li>{$foo}</li>
<? } ?>
Code: Select all
{foreach from=$myArray item=foo}
<li>{$foo}</li>
{/foreach}
Its not called "native templating".. its not called anything.. its like drinking water from a glass.. its just what you do. php is an embeddable language. Much like javascript. But php gets translated before the web server loads the page, javascript is done on the clients browser.
You set variables in the controller files that are used in the view files. If you want to show the product name for example. You do a database query in the controller for that product, and then set the name value to a variable that the view will use. The view is simple html. You can make tables and divs and images like any other static webpage. The only difference is that for displaying the variable that you set, you simply enclose the variable in tags <?php and ?>.
So if the variable set is $product_name then in the html file you would type
<?php echo $product_name; ?>
Thanks for the clarification. I will study the code used to build Open Cart to understand the logic flow. When I did searches on PHP and Templating, I got a lot of hits on SMARTY. I assumed from that it must be widely used or at least talked about. I have a book by W. Jason Gilmore on "Begining PHP", he spends an entire chapter on SMARTY and he is pretty well-known PHP author. http://www.easyphpwebsites.com/
I am not a SMARTY endorser, I am just trying to get other peoples perspective on it. Thanks again.
I am not a SMARTY endorser, I am just trying to get other peoples perspective on it. Thanks again.
Who is online
Users browsing this forum: No registered users and 12 guests