/    Sign up×
Community /Pin to ProfileBookmark

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.

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@ginerjmSep 04.2018 — One can do this without worrying about any other tools. Just begin your script with startup php settings such as enabling error checking, opening a session, retrieving any session variables and grabbing the inputs that your script may or may not have been provided with. Then write the necessary php code to handle your current appl. status and then proceed to write the presentation code.

Personally I place 90% of my presentation (html/js) code in a php function at the end of my script. I place php vars containing dynamic output at specific places within that function. When I have finished my php processing and prepare those dynamic vars I then call this function and then exit my script. I make good use of the heredocs function/construct in this function so as to make writing my html/js code that much simpler.
Copy linkTweet thisAlerts:
@NogDogSep 04.2018 — PHP _is_ a templating language already, so I've always found things like Smarty to be overkill. It adds some handy functions for doing some presentation things -- but underneath they are _PHP_ functions, so could simply be a plain old PHP library of functions/classes.

Anyway, the important thing is not what tool you use, but that you actually separate concerns into different parts of the applications: often/usually separate files that concentrate on that specific thing. This it the essential idea behind the use of a MVC framework: model files to handle business logic and such, views for the presentation layer, and controllers to tie everything together.
Copy linkTweet thisAlerts:
@rickymicheal821Sep 04.2018 — Everybody who has a computer or knows how to work on one has used Microsoft Office at some point or the other. For most of the people, Microsoft office has been there to help them throughout their digital lives. From writing college essays to making presentations, to creating emails on outlook to calculating budget on Excel, Microsoft Office has been there. The popularity of Microsoft Office is so high that over a billion people use the Microsoft productivity suite.  Office 2016, Office 2013,Office 2010,Office 2007,and Office 2003 are some of the desktop versions of Microsoft Office.

[upl-image-preview url=https://www.webdeveloper.com/forum/assets/files/2018-09-04/1536072288-456044-image.png]

https://askmesetup.com/
Copy linkTweet thisAlerts:
@ginerjmSep 04.2018 — Who is this? A M$ shill? Obviously not a programmer. I can't imagine using Word to write code. It would be so laughable!!!!
×

Success!

Help @cali88 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...