EllisLab text mark
Advanced Search
     
views and controllers
Posted: 01 May 2011 08:45 AM   [ Ignore ]
Joined: 2010-12-29
5 posts

I have several controllers that load the same views (besides specific views for each controller).
Is there a way to do it only once ?

 
Posted: 01 May 2011 09:01 AM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2009-06-19
6267 posts

Create a template_view, something like this add more if you need them.

<?php $this->load->view(header_view);?>

<?php $this
->load->view(body_view);?>

<?php $this
->load->view(footer_view);?> 

Controller:

$this->load->vars($data);
$this->load->view('template_view'); 

InsiteFX

 Signature 

Ceritfied State of CT Computer Programming Teacher.
Custom Designed Icons, eBook Covers Software Boxes. CD, DVD Etc. New iPhone® Tab Bar Icons and iPhone® Applications Icons.

STOP! Before posting your questions, remember the WWW Golden rule:
What did you try? What did you get? What did you expect to get?

Input -> Controller | Processing -> Model | Output -> View

 
Posted: 01 May 2011 11:12 AM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Joined: 2010-12-29
5 posts

thanks but what I meant was regarding the $data…

 
Posted: 01 May 2011 11:28 AM   [ Ignore ]   [ # 3 ]   [ Rating: 0 ]
Avatar
Joined: 2011-04-30
45 posts

you mean this?

<?php
$data[‘body’]=“view body content”;
$this->load->view(‘body_view’,$data);
?>

 Signature 

Pinoy/PHP Developer/Codeigniter

My Blog

 
Posted: 01 May 2011 02:39 PM   [ Ignore ]   [ # 4 ]   [ Rating: 0 ]
Avatar
Joined: 2009-06-19
6267 posts

You mentioned nothing about data all about views!
Then look into creating a MY_Controller in the CodeIgniter User Guide

This can be used any place in your code and makes the data avaiable to all your views!

$this->load->vars($data); 

InsiteFX

 Signature 

Ceritfied State of CT Computer Programming Teacher.
Custom Designed Icons, eBook Covers Software Boxes. CD, DVD Etc. New iPhone® Tab Bar Icons and iPhone® Applications Icons.

STOP! Before posting your questions, remember the WWW Golden rule:
What did you try? What did you get? What did you expect to get?

Input -> Controller | Processing -> Model | Output -> View