Welcome Guest, Not a member yet? Register   Sign In
error using load vars
#1

[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
#2

[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.
#3

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

[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.
#5

[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
#6

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

[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
#8

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




Theme © iAndrew 2016 - Forum software by © MyBB