php - CodeIgniter Initial Page Load Variable? -


i'm looking solution loading header/footer/navigation on initial page view.

the reasoning behind navigation panel uses ajax render content of destination link in main content div instead of loading page itself.

however, need able along lines of if initial view, load header, navigation, actual page, footer. if not initial view , page loaded in content div area example navigation link or form submit, doesn't load header, navigation , footer actual page.

so example have these 4 views:

header_view navigation_view page_a_view footer_view

and controller:

controller_a

the navigation has link 'page a' , points http://myurl.com/controller_a. if link clicked wanted controller_a load page_a_view view, because navigation link load data of page div.

however if directly go http://myurl.com/controller_a, needs render the header/navigation/footer also.

the solution thought on right lines base controller function load_page() like:

function load_page($page, $data) {      if($this->uri->segment($this->uri->total_segments()) == "initial_page_load") {         $this->load->view('header_view');         $this->load->view('navigation_view');         $this->load->view($page, $data);         $this->load->view('footer_view');     } else {         $this->load->view($page, $data);     }  } 

so if go http://myurl.com/controller_a/initial_page_load load header/navigation/footer if went http://myurl.com/controller_a wouldn't.

however doesn't cover possibilities.

another way thought of checking if there referring url, if there is, don't load header/navigation/footer. again, doesn't cover things such if link referred external website?

does have suggestions how can achieve need?

let view page views. other pages, going change content on div, 'page_content' dynamically via ajax.

**application/views/your_template_view.php** <?php     $this->load->view('header_view');     $this->load->view('navigation_view'); ?> <a href="javascript:void(0)" id='home' class='my_links'>home</a> <a href="javascript:void(0)" id='about_us' class='my_links'>about us</a>  <!--     make sure id of page same      file name of view page respective pages  -->  <div id='page_content'><?php echo $page_content; ?></div>  <?php     $this->load->view('footer_view'); ?> <script lang='javascript'>     $('.my_links').click(function(){         $.post(             '<?php echo site_url('test_controller/get_page_content') ?>',             {'page_content':$(this).attr('id')},                 function(response){                     if(response != '')                         $('#page_content').text(response);                 },'json'         );     }); </script> 

let controller :

**application/controller/test_controller.php** function your_page($param1 = '', $param2 ='') {     /*this 1 initial page*/     if($param1)         // send mail     if($param2)         // send mail      $data['page_content'] = $this->load->view('initial_page_load');     $this->load->view('your_template_view', $data);  } function get_page_content() {     /*this 1 other pages, provides page content        request made ajax*/     $page_title = $this->input->post('page_title');     $page_content = $this->load->view($page_title);     echo json_encode($page_content); } 

Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -