Welcome Guest, Not a member yet? Register   Sign In
How to use MY_Controller.php and show the pages
#1

[eluser]ytsejam[/eluser]
Hello ,
I am trying to finish my first application with CI. I used MY_Controller. My first problem is when opening the page It loads an animation to lay menu and content each side of the page. So I want only content part change. And my application has a directory structure :
+Home
+About
+Services
+Education
+Biofeedback
+Neurofeedback
....
MY_Controller.php

Code:
function render_page($view) {
    //do this to don't repeat in all controllers...
    $this->load->view('templates/header', $this->data);
    //menu_data must contain the structure of the menu...
    //you can populate it from database or helper

    $this->load->view($view, $this->data);
    $this->load->view('templates/menu');
    $this->load->view('templates/footer', $this->data);
  }

My routes.php :
Code:
$route['default_controller'] = 'home/view';
$route['(:any)'] = 'home/view/$1';
How can i code the database based menu to show pages/home.php or pages/about.php type menu file and make only content of the page change ?

#2

[eluser]pickupman[/eluser]
For a backup plan, you want to make sure it is working normally right now where the whole page get regenerated on click. The type of behavior you are looking for is used in jQuery mobile. jQuery parses the page load and only changes the page (DOM) based on the content.

The other similar option is to use jQuery .load() and when a link is clicked, use your render_page method to only output the content on AJAX request.
Code:
function render_page($view) {
    if( ! $this->input->is_ajax_request() )
    {
      //do this to don't repeat in all controllers...
      $this->load->view('templates/header', $this->data);
      //menu_data must contain the structure of the menu...
      //you can populate it from database or helper
    }
    $this->load->view($view, $this->data);
    if( ! $this->input->is_ajax_request() )
    {
     $this->load->view('templates/menu');
     $this->load->view('templates/footer', $this->data);
    }
  }




Theme © iAndrew 2016 - Forum software by © MyBB