Welcome Guest, Not a member yet? Register   Sign In
Problem with Organizing Views in Folders
#1

[eluser]CARP[/eluser]
Hi guys
I'm having a little problem trying to organize views in subfolders.
I've created (and divided) the views in:

views/inc_header.php
views/inc_footer.php

Then I've a view file stored in
views/parameters/city

And in the view file, I have:
Code:
<?
include("../inc_header.php");
?>

but I'm getting the following

Severity: Warning
Message: include(../inc_cabecera.php) [function.include]: failed to open stream: No such file or directory
Filename: parameters/city.php
Line Number: 2


Thanks a lot in advance for any tip you can give me
#2

[eluser]n0xie[/eluser]
Code:
<?php
$this->load->view('inc_header');
?>
#3

[eluser]CARP[/eluser]
[quote author="n0xie" date="1257399141"]
Code:
<?php
$this->load->view('inc_header');
?>
[/quote]

worked great!, but got another problem
In the file views/inc_header.php I had the following:

Code:
$dir_views = $this->config->item('dir_views');

and I can't use or reference to $dir_views in the file: views/parameters/city.php (I get an error). I've fixed this temporarily by copying the above line of code to each view...

Smile
#4

[eluser]Jamie Rumbelow[/eluser]
You can pass through any variables to any of the views you load by passing through an array of keys as variable names and values as the variable value as the second parameter to the $this->load->view() function. For instance, if you wanted to pass through the $dir_views variable to the parameters/city.php view:

Code:
$dir_views = $this->config->item('dir_views');

$data = array(
    'dir_views' => $dir_views
);
$this->load->view('parameters/city', $data);
#5

[eluser]CARP[/eluser]
That's a better way Jamie
Thanks to Everyone




Theme © iAndrew 2016 - Forum software by © MyBB