CodeIgniter Forums
loading view with dinamic data, best practices - Printable Version

+- CodeIgniter Forums (
+-- Forum: Archived Discussions (
+--- Forum: Archived Development & Programming (
+--- Thread: loading view with dinamic data, best practices (/thread-37300.html)

loading view with dinamic data, best practices - El Forum - 01-05-2011

Hello all, I'm doing my first steps in CI, and therefore i would like have your opinion on the best practices.

In my current project I'm using a view with a defined structure (template) that loads dynamic data according to the url used.

This dynamic data is quite extensive array of strings.

Currently I'm storing these arrays as properties of my controller class, and i'm passing the correct array to the view after analyzing the url, and it works fine.

My Controller looks like this:
class Press_release extends Controller {
  private $data;
  private $tags = array (
                    'create' => array (
                        'event' => array(
                                          'heading_1' =>'Create',
                                          'heading_2' =>'Event'
                        'news'=> array(
                                          'heading_1' =>'Create',
                                          'heading_2' =>'News'

  function create($type){


My View looks like this:
<h1>&lt;?php echo heading_1?&gt;</h1>
<h2>&lt;?php echo heading_2?&gt;</h2>

My problem is that my array with strings is getting too extensive and it makes my controller code very long. I would like to handle this dynamic data as separate php files where i only define the array with the strings (in my case one file for event, and another file for news), much like CI language files.

But without using include statements how can i do that in CI?

I tried to load the php files with the array from within my current view using both:
but in both cases it seems the variables are not passed to the view.

What is the best practice to do something like this?
Can you please advise me?

Thanks in advance.