CodeIgniter Forums

Full Version: error using load vars
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]Asinox[/eluser]
hi guys, i have a error just in the homepage, (index), CI cant find the index view, i'm using a master template, and loading the content view with load vars.

this happen when the url is "http://www.domain.com" and all is fine if the url is " http://www.domain.com/site"

My index function controller Site:

Code:
function index(){
    $data['titulo'] = 'Title';        
    $data['main'] = 'home';
    $this->load->vars($data);
    $this->load->view('master_page');
}


My master_page calling the home view
Code:
<div id="contenido">
    &lt;?php $this->load->view($main);?&gt;
</div>
but this happen just in the remote host, in my local host all is fine...

any idea?

thanks

El Forum

[eluser]jbreitweiser[/eluser]
Check through the souce code in your browser on the local host. Maybe there is an error or warning that the remote host is not allowing to display. Some servers are set to hide any errors from end users.

El Forum

[eluser]danmontgomery[/eluser]
You're trying to access $this in a view...?

El Forum

[eluser]jbreitweiser[/eluser]
You can access the $this var in a view. Its not preferable because of the seperation of view and logic, but to include other views in a view I think its perfectly fine. I include my header and footer sections this way normally.

El Forum

[eluser]Asinox[/eluser]
I dont know why the error, why the variable "main" is undefined, just in remote
Code:
A PHP Error was encountered
Severity: Notice

Message: Undefined variable: main

Filename: views/master_page.php

Line Number: 53

AN ERROR WAS ENCOUNTERED
Unable to load the requested file: .php

El Forum

[eluser]jbreitweiser[/eluser]
Try loading the view like this:
Code:
function index(){
    $data['titulo'] = 'Title';        
    $data['main'] = 'home';
    $this->load->view('master_page', $data);
}

El Forum

[eluser]Asinox[/eluser]
ejej thanks jbreitweiser por reply, but im trying all way ejej and nothing...

i have another website in the same server, and in all website im using this way with load->vars(), i dont know where is my problem:

Working: http://www.site.com/index.php/site

not-working: http://www.site.com/index.php or http://www.site.com

CONTROLLER
Code:
&lt;?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Site extends Controller{
    
    function Site(){
        parent::Controller();
        $this->output->enable_profiler(FALSE);    
        error_reporting(0);
    }    
    
    function index(){
        $data['titulo'] = 'Un site mas';        
        $data['main'] = 'home';
        $this->load->vars($data);
        $this->load->view('master_page');
    }
    function info(){
            phpinfo();
    }
    
    function bienvenida(){
        $data['titulo'] = 'Un site mas';        
        $data['main'] = 'bienvenida';
        $this->load->vars($data);
        $this->load->view('master_page');
    }
}
.HTACCESS
Code:
RewriteEngine on  
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico)  
RewriteCond %{REQUEST_FILENAME} !-f  
RewriteCond %{REQUEST_FILENAME} !-d  
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]
I dont know where is the error..but i cant see how fix it

El Forum

[eluser]Asinox[/eluser]
Fixed with the CI version 1.7.1, just this