All methods of separating presentation from code

I need to figure out the topic of separating presentation from code (all methods). I know that there is Smarty and this is called a templating engine. Do I always use something like a templating engine, or how would this work. I basically need to create a simple website with all possible methods of separating presentation from code.

Thanks.

Here’s a topic I created a few months back that describes how you can do this in procedural.

https://www.sitepoint.com/community/t/how-to-write-proper-php/301523/8

Thats two URLS jammed together. Flagged for a moderator to separate if mr. trooper doesnt return :stuck_out_tongue:

Smarty is heavily outdated. If you want a templating system you should look at Twig.

Could you perhaps clarify what your goal is and what “all methods” means in this context? Are you writing some kind of tutorial? Or just trying to figure out what to use for you next app?

I was looking at the Smarty page and it looks like they updated the script like 6 months ago. So the Twig would be this #1 thing? I would like to include in something like tube script (videos and pic galleries), blog script (cms), forum script. I want to write these projects procedural and oop (2 separate versions for each, so six total). I basically need something for this. One thing for all could be the best as I would need to learn that just one thing. I am also learning Laravel right now and it looks like this is related (Symfony and Laravel has two different ones and one of them is better and people use the one from Symfony or something like that, it could be this Twig). Thanks a lot, but yes, basically looking for this best thing now, or like the best three so I can go from there (go to the urls, research).

Laravel has blade as templating language, although I’m sure you could get it to work with Twig too if you wanted to.

Is Twig or Blade something that people would use in a tube, blog or forum script intended to be on sale on the Internet. It would not sound like this… Smarty I know that gets used but you mentioned that this is old. So what is the best way to go here? Brand new, fresh blog (cms), forum, and tube script 2020, for sale on the Net. How would I do this there (it has to be good, competitive, sell; talking Mercedes or BMW of the scripts).

Sorry, from the quick read, I thought it was about ways to separate methods. The topic I linked is for custom separation. If the OP is using a 3rd party framework to separate their files, then kindly disregard the link I posted. But if the separation of methods is for a custom website that doesn’t use 3rd party framework, then it’s doable.

I honestly don’t think people who buy the product know what a template renderer is, let alone care which one you use.

I would recommend just read up on all of them and decide which one you like best.

Lets say that the customers of this are “the best php or website programmers in the World” and they will be selecting the best product out of what is there (100 separate scripts, very competitive). I guess my choice is
a) one of the “template renderers” from google.com, I will look into this (Smarty is one of them, Blade, Twig, I’ve seen some custom made on gitHub.com)
b) make my own

I would just need to know what the final goal of this could be and then go in this direction. Pick one (which one) or make my own? I can learn about the individual aspect but I have no idea about the overall reality of this. What this is now, what would be the best.

I would suggest to at least take one of the bigger names, so Blade or Twig.

I’d steer clear from custom made as they probably made to solve some very specific problem for someone, and are not general purpose, which is what you’d want.

I’d also avoid writing it yourself, as there’s a lot of complexity in there you’d have to create and maintain.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.