• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need Help Passing Controllers/Views As Arrays

#1
[eluser]razerone[/eluser]
Hi I am need to pass a couple of views as arrays how do I do so.

I came up with this but not quite working.

Code:
$this->children = array(
      'common/footer',
      'common/header'
);

#2
[eluser]PravinS[/eluser]
you can also try like this

$data['footer'] = 'common/footer';
$data['header'] = 'common/header';
$this->load->view('template',$data);


and include this views in view as

include($header);
include($footer);

#3
[eluser]razerone[/eluser]
[quote author="PravinS" date="1382704728"]you can also try like this

$data['footer'] = 'common/footer';
$data['header'] = 'common/header';
$this->load->view('template',$data);


and include this views in view as

include($header);
include($footer);
[/quote]

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Home extends CI_Controller {

public function index() {

$this->load->helper('array');
$this->load->helper('path');

if (file_exists('views/theme' . 'default/template/common/home.tpl')) {
$this->load->view('theme'. 'default/template/common/home.tpl');
}
else {
$this->load->view('theme/default/template/common/home.tpl');
}

$this->children = array(
'common/footer',
'common/header'
);
}
}

This is way I have done but need to use array or some thing suitable

#4
[eluser]PravinS[/eluser]
try using

in controller
Code:
$children = array("common/footer","common/header");
$data['children'] = $children;


in view
Code:
foreach($children as $file)
{
     if (file_exists($file))
         include($file);
}

#5
[eluser]razerone[/eluser]
[quote author="PravinS" date="1382707432"]try using

in controller
Code:
$children = array("common/footer","common/header");
$data['children'] = $children;


in view
Code:
foreach($children as $file)
{
     if (file_exists($file))
         include($file);
}
[/quote]

No Luck


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.