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

  • SEARCH
  • Home
  • 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 232239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T20:00:02+00:00 2026-05-11T20:00:02+00:00

With a CMS (PHP/MySQL) that’s getting bigger and bigger and its code harder to

  • 0

With a CMS (PHP/MySQL) that’s getting bigger and bigger and its code harder to maintain, I’m thinking of applying an MVC model to make it more maintainable and transparent. I’ve been doing some catch-up on the subject, and I think I have it pretty much figured out, except for the views part. Here’s what I have in mind so far:

index => controllers <=> models
         controllers  => views

An index.php that acts as the main controller (router) and creates instances of controller classes based on params in the URL. The controller classes talk to a model classes for updating and retrieving information in/from the database. And after that the controller makes sure the view (in the form of templates) is displayed and receives processed data to display. However…

The idea is to shift all the logic from the view to the controller, right? Or at least away from the view — to prevent a fat/skinny controllers/models discussion. But whichever way I look at it, I still need somewhat dynamic views and that will also require some logic. For instance displaying certain options for certain users based on their user level and rights (update, update/delete, etc.). So that will come down to if/else statements and things like that. Is this OK? And if so, how much of this ‘simple’ logic is ‘allowed’? My take is up to a point where a different template starts to make more sense (e.g. profile_view and profile_edit).

Another simple example. Say one user can see 5 out of 10 profile fields, and another user 10/10. Should I retrieve all the information for all 10 fields through the controller, and determine in the view whether or not to display it? Or move those kinds of decisions to the controller as well, and retrieve information for either 5 or 10 fields and display only the available fields in the view based on the information that has been passed on? Because in many situations it’s much easier have all the data and disregard some of it, opposed to not knowing what is available and having to check for that all the time.

  • 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-11T20:00:02+00:00Added an answer on May 11, 2026 at 8:00 pm

    “So that will come down to if/else statements and things like that. Is this OK?”

    Yes.

    “how much of this ‘simple’ logic is ‘allowed’?”

    Simple if-else and simple loops must be present in the view templates.

    No calculations. No form-handling logic. None of that.

    If you look at some of the more sophisticated frameworks, you can see some examples. Indeed, you should probably just use a framework instead of rolling your own.

    [If you have the patience to read the Python-based Django template documentation, you can see what should be allowed. There are probably some PHP frameworks with a similar philosophy.]

    “Say one user can see 5 out of 10 profile fields, and another user 10/10”

    There are several approaches.

    1. Two different page templates showing the same underlying data. You fetch everything,
      but pick a template appropriate to the user.

    2. One complex template showing variant underlying data. You fetch everything, provide suitable flags, and send to a template which uses template-side if-statements.

    Which is “better”? Depends on your appetite for complex pages. Personally, I’d prefer to have two simple pages and use some kind of inheritance to factor out the common features. I don’t like if-statements, they’re a cause of problems down the road. OTOH, some folks like if-statements and don’t mind the complexity.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 121k
  • Answers 121k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I re-read the question, here is a function that would… May 12, 2026 at 12:33 am
  • Editorial Team
    Editorial Team added an answer You could try including the compiler file version in your… May 12, 2026 at 12:33 am
  • Editorial Team
    Editorial Team added an answer template<class InputIterator> void add_all_msgs(InputIterator iter); Usage: std::deque<Message> deq; add_all_msgs(deq.begin()); May 12, 2026 at 12:33 am

Related Questions

With a CMS (PHP/MySQL) that's getting bigger and bigger and its code harder to
I have the task to build a web-site for a smaller non-profit organization. I
We are looking for a way to publish articles in different languages, including differences
I am looking for a good eCommerce CMS. I need to be able to
I developed a web application, that permits my users to manage some aspects of

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.