Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4119584
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T23:06:33+00:00 2026-05-20T23:06:33+00:00

I read this post and I really like this solution to templating but I

  • 0

I read this post and I really like this solution to templating but I am unsure of one thing. With this system wouldn’t the business logic and presentation logic be in two different php files? This is all well and good as it separates them but what if there is only presentation logic as there are on some pages or what if there is a very low amount of business logic?

It seems weird that the default page the users page to will sometimes be only presentational logic and sometimes only business logic. It seems like there are two obvious solutions to this:

1) Have all default pages have business logic (even if there is none) that link to the presentational logic on a different page. The problem with this is that there are then a lot of “unnecessary” pages. The good is that it is consistent.

2) If there is no business logic for a page then just only include the presentational logic. The problem with this is that it is inconsistent when looking at filenames as to what php page includes the business and presentational logic.

Also, and this may be a little off-topic, but is there any way to template this?

<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>My Website</title>
        <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
        <link href="styles.css" rel="stylesheet" type="text/css"/>
        <link href="favicon.png" rel="shortcut icon" />
    </head>
    <body>
    </body>
</html>

Considering I have this on every page I was wondering if there was a way to template this so the code could all be in one file and recalled.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T23:06:34+00:00Added an answer on May 20, 2026 at 11:06 pm

    Your templates should contain strictly presentational logic.

    This means that you can include:

    • Loops (to print lists etc)
    • Conditionals (e.g. only print an element if some value is non-null)
    • Formatting functions (strip spaces, round numbers, etc)
    • A small number of template-composition helper function calls (e.g. “please include this other sub-template here”)

    but nothing else — and especially not business logic! (if I forgot something important, please mention it in a comment)

    Also, your templates (“views”) should never be used as the target URLs that you application uses. You should have the URLs point to (possibly one of many) “controller” scripts, which then invoke the necessary business logic and pass the results to your template for display by including the template. You will find this easy to grasp if you are familiar with Model-View-Controller; if you are not, familiarize yourself first.

    Finally, here’s one way you could template the markup you gave:

    <html xmlns="http://www.w3.org/1999/xhtml">
        <head>
            <title><?php echo $title;?></title>
            <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <?php foreach ($stylesheets as $stylesheet) : ?>
            <link href="<?php echo $stylesheet;?>" rel="stylesheet" type="text/css"/>
    <?php endforeach; ?>
            <link href="favicon.png" rel="shortcut icon" />
        </head>
        <body>
        </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just read this post about why new-line warnings exist, but to be honest
I read some post in this regard but I still don't understand what's the
I read this post last night, and I noticed it was from 2006. I
I have read this post about how to test private methods. I usually do
Just finished read this post by Greg Young, where he is talking about Microsoft
I read this PHP RegEx page , but either I'm missing something, misreading something,
I read this answer and its comments and I'm curious: Are there any reasons
I read This article and i found it interesting. To sum it up for
Update: Please read this question in the context of design principles, elegance, expression of
Today I read this blog entry by Roger Alsing about how to paint a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.