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 6663059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:27:28+00:00 2026-05-26T02:27:28+00:00

Since I decided to reinvert the wheel and write a growing MVC, I though

  • 0

Since I decided to reinvert the wheel and write a growing MVC, I though having a template class will be cool. Now I have never done any complex templating apart from simple include kind of templating. Now I wrote this base class and here is my concept is explained below. Is this right way/concept of writing web page templates?

Concept
“Any Template class will extend this class. The Controller will modify single part or all. If controller will modify the content only using set action, then the page will change only one component and other parts will remain the same just like including header/footer would do”

Another question is,how do I pass same page object so that non changed parts are cached in the object (since http is stateless protocol)? Should I start session and store it object in session? Should parent be a singleton?
Thanks!

<?php

class TemplateBase{
    //variables corresponding to part of web page
    private $header;
    private $footer;
    private $body;
    private $menu;
    private $left_side;
    private $right_side;
    private $menu_header;//between menu and header
    private $menu_content;//between menu and content

    public function __construct(){
        //no inits for now
    }

    //header
    public function header_func($action, $value=null){
        if($action=="get"){
            return $this->header;
        }

        if($action=="set"){
            $this->header = $value;
        }
    }

    //footer
     public function footer_func($action, $value=null){
         if($action=="get"){
            return $this->footer;
        }

        if($action=="set"){
            $this->footer = $value;
        }
    }

    //body
     public function contents_func($action, $value=null){
         if($action=="get"){
            return $this->body;
        }

        if($action=="set"){
            $this->body = $value;
        }
    }

    //left side
     public function left_bar_func($action, $value=null){
         if($action=="get"){
            return $this->left_side;
        }

        if($action=="set"){
            $this->left_side = $value;
        }
    }

    //right side
     public function right_bar_func($action, $value=null){
         if($action=="get"){
            return $this->right_side;
        }

        if($action=="set"){
            $this->right_side = $value;
        }
    }

    //menu
     public function menu_func($action, $value=null){
         if($action=="get"){
            return $this->menu;
        }

        if($action=="set"){
            $this->menu = $value;
        }
    }

    //between menu and content
     public function menu_content_func($action, $value=null){
         if($action=="get"){
            return $this->menu_content;
        }

        if($action=="set"){
            $this->menu_content = $value;
        }
    }

    //between menu and header
     public function menu_header_func($action, $value=null){
         if($action=="get"){
            return $this->menu_header;
        }

        if($action=="set"){
            $this->menu_header = $value;
        }
    }

}

/*End of file*/
  • 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-26T02:27:29+00:00Added an answer on May 26, 2026 at 2:27 am

    That approach is not much of a templating class. It just collects a few page part snippets as it looks.

    Your methods are downright awful, if I may say so. Using $action=="get" and =="set" is even worse than the widespread getter and setter methods which this supposedly emulates. (Making attributes private or protected just because the syntax exists or because of some security or proper coding myth does not make much sense.)
    And then calling the methods attribute_func() is likewise uselessly repetetive.

    Make it an array. Assign your html snippets there.

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

Sidebar

Related Questions

In my compilers class, I decided to write my compiler in Python since I
Since I have decided to let RC go while staying with Beta for now,
I have finally decided to go with the Entity Framework since it has the
Since last August 2009, I have been working on project but then decided to
I am trying to learn ASP.NET (since I know C#) so I have decided
I decided to use UIScrollView in my application since I have to scroll the
I'm struggling with this since a few days now and finally decided to ask
Since black red tree is a binary search tree I have decided to use
Since I have been mostly using script languages in the past time but now
I have been an avid TFS user since 2005 but decided to skip the

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.