Welcome Guest, Not a member yet? Register   Sign In
pass data fom view to inlcuded views and back
#1

Hello,

i try to create a kind of templateset,

in my controller i call the mainpage like this
"
$data['view_page']= $page;  //here is the main-content-filename for example "login" (.php)
$data['view_data']= $dataP; //Some data
echo view('templates/v1/create_page', $data);
"

in the "create_page" i include a lot of single files to seperate the different parts like this
"
    $data['data']=$view_data;                  //pass some data from controller to subfiles !?

    $this->include($view_page,$data);  //here i include my main-content-file for example "login"

  //from this mainfile i need access to the $data vars in the following files, but all my tries failed. Is it possible? How?

  $this->include('templates/v1/head',$data);
  $this->include('templates/v1/header',$data);
  $this->include('templates/v1/sidebar_left',$data);

"

main-content-file for example "login"
"
  //The following $data i need in the mainpage AND also included files like head, header etc. (as shown on top)
$data['view_template']=array(  'val1'  =>  'default', 'val2'=>''...);

$this->section('title') ?>Some content here <?= $this->endSection() ?>
"
 
Hope i could explain what i want to do?
Reply
#2

Sessions / Cookies?
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

yes thats always a way, good idear, but, is there no direct way to pass the vars to the file?
Reply
#4

Instead of using:

PHP Code:
$this->include('templates/v1/head',$data);
$this->include('templates/v1/header',$data);
$this->include('templates/v1/sidebar_left',$data); 


I suggest you use:

PHP Code:
echo view'templates/v1/head',$data);
echo 
view('templates/v1/header',$data);
echo 
view('templates/v1/sidebar_left',$data); 
Dirk B.
ESD Digital
No SEO spam - see forum guidelines
Reply




Theme © iAndrew 2016 - Forum software by © MyBB