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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:11:35+00:00 2026-05-24T09:11:35+00:00

How do people construct websites with cake/CI ect… for easy maintenance on the html?

  • 0

How do people construct websites with cake/CI ect… for easy maintenance on the html?

I can put each of the sections in its own view file and make the website that way:

<div id="header"></div> <!-- header_view.php -->
<div id="content"> <!-- header_view.php -->
    <div id="left_column"></div> <!-- page_x_view.php -->
    <div id="center_column"></div> <!-- page_x_view.php -->
</div>
<div id="footer"></div> <!-- footer_view.php -->

But each page_x_view.php file would contain

<div id="left_column"><!-- Content --></div>
<div id="center_column"><!-- Content --></div>

And I’m duplicating these items through each of the files, so if I need to change the column structure then it is not easy.

Hopefully I am clear.

  • 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-24T09:11:36+00:00Added an answer on May 24, 2026 at 9:11 am

    I have a controller caled MY_Controller which has a method that renders the complete page. I extend all my controllers from this main controller. HOw this helps? My main controllers takes a view and embedds it in the main content area of page and assembles a complete page. This controller takes header, footer, sidebar views and does all the mambo jumbo. Its very easy to develop such a system in CI. Some this call two step or multiple views. So if some random day I have to change layout of my page I just need to look at MY_Controller.

    Cake on the other side uses layouts. I have done just one project in CakePHP so am not that expert but you can achieve the same effect in any framework. Here is how I do it in CI

    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
    
    class MY_Controller extends CI_Controller 
    {
    
        public function __construct() 
        {
            parent::__construct();
            log_message('debug', 'Controller Library '.__CLASS__ . ' ('. __FILE__ .') loaded.');
            $this->properties['viewPath'] = $this->config->item('viewPath');
            $this->setPageMetaData();
            $this->setFavIcon();
    
        }
    
        public function render($viewData = null, $data=null)
        {
            $data = array(
                'headerLayout' => $this->printHeaderLayout(array_merge($this->properties, (isset($data['headerLayout'])?$data['headerLayout']:array()))),
                'leftLayout' => $this->printLeftLayout(array_merge($this->properties, (isset($data['leftLayout'])?$data['leftLayout']:array()))),
                'rightLayout' => $this->printRightLayout(array_merge($this->properties, (isset($data['rightLayout'])?$data['rightLayout']:array()))),
                'footerLayout' => $this->printFooterLayout(array_merge($this->properties, (isset($data['footerLayout'])?$data['footerLayout']:array()))),
                'containerLayout' => $viewData,
            );
            this->load->view($this->properties['viewPath'].'layout/layout.php', $data);
        }
    
        public function setPageMetaData($pageMetaData=null) 
        {
            $this->properties['pageTitle'] = isset($pageMetaData['pageTitle'])? $pageMetaData['pageTitle'] : $this->config->item('pageTitle');
            $this->properties['pageKeywords'] = isset($pageMetaData['pageKeywords'])? $pageMetaData['pageKeywords'] : $this->config->item('pageKeywords');
            $this->properties['pageDescription'] = isset($pageMetaData['pageDescription'])? $pageMetaData['pageDescription'] : $this->config->item('pageDescription');
        }
    
        public function setFavIcon($favIcon=null) 
        {
            $this->properties['favIcon'] = (null !== $favIcon) ? $favIcon : $this->config->item('favIcon');
        }
    
        public function printHeaderLayout($data=null)
        {
            return ($this->load->view($this->properties['viewPath'].'layout/header', $data, true));
        }
    
        public function printFooterLayout($data=null)
        {
            return( $this->load->view($this->properties['viewPath'].'layout/footer', $data, true));
        }
    
        public function printLeftLayout($data=null)
        {
            return($this->load->view($this->properties['viewPath'].'layout/left', $data, true));
        }
    
        public function printRightLayout($data=null)
        {
            return($this->load->view($this->properties['viewPath'].'layout/right', $data, true));
        }
    }
    

    Do note that this is not the exact code. I had to modify it for you, so do not blindly user it. If you know CI you will understand that I have setup paths to view in a config file. This helps me in setting up two totally different themes and use same controller. I can also add authentication layer which will based on user authentication/cookies can show a login or logout link in header. This is a template which I keep change and I extend all my controllers from MY_Controller and use in my controllers I simply do

     $viewDataForForm = $this->load->view($this->properties['viewPath'].'homepage/some-form', array(), true);
     $viewDataForContent = $this->load->view($this->properties['viewPath'].'homepage/some-content', array(), true);
     $this->render($viewDataForForm.$viewDataForContent);
    

    HTH!

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

Sidebar

Related Questions

I want to construct a transact sql script that will stop specified people from
People have been developing own solutions to the following problems: Consistent messaging frameworks for
In ML-family languages, people tend to prefer pattern matching to if/else construct. In F#,
People keep giving me examples with carp instead of warn. Why? What makes carp
People use frequently something like: <ListBox ItemsSource={Binding ElementName=thisControl, Path=ListIndexes}> <ListBox.ItemTemplate> <DataTemplate> <StackPanel> <Label Content={Binding
People always advised me that if I am doing some application that should use
People buy stuff in a web shop. I take their orders and save them
People use gdb on and off for debugging, of course there are lots of
Many people use Mock Objects when they are writing unit tests. What is a
Most people say never throw an exception out of a destructor - doing so

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.