Welcome Guest, Not a member yet? Register   Sign In
static page -> dynamic page in 5 minutes
#1

[eluser]lucid[/eluser]
Hi everyone Wink

I have a website with.. about 15 pages, but all of them includes the same header and footer (simple include function Wink.

First, I wanna "remake it" - using this framework and I just want to confront You with my idea - as a total newbie.

I will create one controller, let's call it pages, with method view(), and it goes like that:

Code:
class Pages extends CI_Controller {
public function view($page = 'home') {

  $this->load->view('templates/header');
  $this->load->view('pages/'.$page);
  $this->load->view('templates/footer');
  
}//view

} //class

than in view/templates i create header.php and footer.php

and in view/pages/ I copy the pages html.

Than I need to change my routes, and mod_rewrite in .htaccess so calling for

domain.com/page3.php will actually call domain.com/index.php/pages/view/page3 <- I already know how to do it, it's not a problem.

and that's it. Job is done.

---

But.. I want to remake it with help of framework, because I want to create CMS for easy updating some of those pages. So next step would be to make some of those pages using database to download content.

IF I use this structure, would I be able to do it later? Because when i think of it, the only way to make some pages connecting with database would be calling another controller, exacly from first controller, so I would do it like that:


Code:
class Pages extends CI_Controller {
public function view($page = 'home') {
  $data=0;
  if ($page == "specific1") $data=$this->download("specific1");
  $this->load->view('templates/header');
  $this->load->view('pages/'.$page, $data);
  $this->load->view('templates/footer');
  
}//view

public function download($which_page) {
                
            //  here: connect to database, receive data, return it in array or whatever
} //download

} //class

Is it a good idea ?


Messages In This Thread
static page -> dynamic page in 5 minutes - by El Forum - 01-23-2012, 08:20 AM
static page -> dynamic page in 5 minutes - by El Forum - 01-24-2012, 11:21 PM
static page -> dynamic page in 5 minutes - by El Forum - 01-26-2012, 08:35 AM
static page -> dynamic page in 5 minutes - by El Forum - 01-29-2012, 03:01 PM
static page -> dynamic page in 5 minutes - by El Forum - 01-29-2012, 03:36 PM



Theme © iAndrew 2016 - Forum software by © MyBB