0

I have this template view at view/include

<?php $this->load->view('include/header'); ?>
<?php $this->load->view($sidebar_column); ?>
<?php $this->load->view($result_column); ?>
<?php $this->load->view($footer_row); ?>
<?php $this->load->view('include/footer'); ?>

and i have the footer_row html at view/include

<div> this is footer row <?php echo $username ?></div>

then i call the footer_row in my controller

$data['footer_row'] = 'include/footer_row';
$this->load->view('include/template',$data);

My question, the footer_row is logged in user info and it appear in EVERY pages. With the above method I use, I have to call and retrieve the user info in every controller. How can i make it reusable so i don't need to repeat myself.

2 Answers 2

2

Reusability comes from making use of your constructors, and parent classes. Have a look at my previous answers:

  1. Header and Footer in CodeIgniter
  2. Constructor session validation for different functions
Sign up to request clarification or add additional context in comments.

Comments

0

Instead of using this method why dont you use a template library which is easy to use. I would recommend Philsturgeons Template Library but there are some more you can use any that fits to your requirements.

Williams Concepts

http://williamsconcepts.com/ci/codeigniter/libraries/template/

Phil Sturgeons's

http://philsturgeon.co.uk/demos/codeigniter-template/user_guide/

Most Simple

http://maestric.com/doc/php/codeigniter_template

And Finally Binpresses's

http://www.binpress.com/app/codeigniter-template-library/223

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.