Welcome Guest, Not a member yet? Register   Sign In
[solved] help me finding simple mistake
#1

[eluser]SPeed_FANat1c[/eluser]
I am doing new project with MY_Controller library, it looks that it should work, but it doesn't.

Ok, MY_Controller:

Code:
class MY_Controller extends Controller{
  
  var $data;

  public function __construct(){
    parent::__construct();
    
    //default data
    $this->data['title'] = 'Ylakių globos namai';
    $this->data['meta'] = array(
                0 => '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />',
            );
    $this->data['javascript'] = '';
    $this->data['virsutinis_meniu'] = $this->get_top_menu();
    $this->data['current_menu'] = 99;    //99 reiskia joks meniu nera aktyvus

    /*
    //sidearui
    $this->data['links'] = $this->Views_model->get_links();
    $this->data['banners'] = $this->Views_model->get_banners();
    */
    
    /*
    //footeriui, jie noresim dinaminiu duomenu
    $this->data['footer'] = $this->Views_model->data_for_footer();
    */        
  }
  
  /*
   * paduodam main sekcijos view faila, taip pat kaip ir this load view kai paduodume
   */
  function display($main_view){
  
       $this->load->vars($this->data);
       //echo 'test';
     $this->load->view('header_view');
     //echo 'test2';
     $this->load->view($main_view);
    
     $this->load->view('sidebar_view');
     $this->load->view('footer_view');
  }
  
    private function get_top_menu()
    {
        $this->db->order_by('Eile','asc');
        $query = $this->db->get('virsutinis_meniu');
        return $query->result_array();
    }
}

I try to make simple login function in the controller:

Code:
class Admin extends MY_Controller
{
    
     public function __construct(){
        parent::__construct();
        $this->load->model('membership_model','membership');
          $this->load->helper('form');
      }
      
      
    function index()
    {
    
        if($this->membership->is_logged_in())
        {
            
            $this->data['title'] = 'Administravimas - pagrindinis meniu';
            $this->data['javascript'] = '[removed][removed]
                                                  [removed][removed]';
                        
            $this->display('admin/main_menu_view');    
        }
        else
        {
            $this->login();
        }
    }
    
    function login()
    {
        
        $this->data['title'] = 'Administratoiaus prisijungimas';                
        $this->display('admin/login_view');    
    }
    
    
    
    
}

Header file:

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

&lt;html &gt;
&lt;head&gt;

&lt;?php
    foreach($meta as $val)
    {
        echo $val;
    }
?&gt;
&lt;link rel="stylesheet" href="&lt;?php echo base_url()?&gt;images/Outdoor.css" type="text/css" /&gt;

&lt;title&gt;&lt;?php echo $title;?&gt;&lt;/title&gt;

<s+cript type="text/javascript">
&lt;!--
    var CI = {
      'base_url': '&lt;?php echo base_url(); ?&gt;'
      
    };
--&gt;


</s+cript>
&lt;/head&gt;

&lt;?php
    echo $javascript;
?&gt;
&lt;body&gt;

&lt;!-- wrap starts here --&gt;
<div id="wrap">

    &lt;!--header --&gt;
    <div id="header">            
                
        <h1 id="logo-text"><a href="&lt;?php echo base_url()?&gt;" title="">Ylakiu globos namai</a></h1>        
        <p id="slogan">Seneliu namai</p>        
            
        <div id="header-links">
            <p>
            <a href="index.html">Home</a> |
            <a href="index.html">Contact</a> |
            <a href="index.html">Site Map</a>            
            </p>        
        </div>                
        
    &lt;!--header ends--&gt;                    
    </div>
    
    <div id="header-photo"><img src="images/header-photo.jpg" width="870" height="206" alt="header-photo" /></div>    
    
    &lt;!-- navigation starts--&gt;    
    <div  id="nav">
        <ul>
            &lt;?php
                    $i = 0;
                    foreach($virsutinis_meniu as $key => $val)
                    {
                        if($i == $current_menu)
                             echo '<li id="current"><a href="'.base_url().$val['Nuoroda'].'">'.$val['Pavadinimas'].'</a></li>';
                        else echo '<li><a href="'.base_url().$val['Nuoroda'].'">'.$val['Pavadinimas'].'</a></li>';
                        $i++;
                    }
                ?&gt;
        </ul>
    &lt;!-- navigation ends--&gt;    
    </div>                    
            
    &lt;!-- content-wrap starts --&gt;
    <div id="content-wrap">

I will not post other view files, because I think we don't need them, because I am not even seeing the header file.

When I go to http://localhost/ubagynas/admin/login (my site is in folder 'ubagynas')

I see no errors or anything - only white page. When I check the source code in browser, here is what I see:

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">



&lt;html &gt;

&lt;head&gt;



&lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt;

Have you an idea why there is nothing after metadata? I guess I made some stupid mistake but cannot find Sad
#2

[eluser]Bart Mebane[/eluser]
Are you autoloading the url helper? If that's not the problem, turn on php error reporting. Must be a php error somewhere.
#3

[eluser]Cristian Gilè[/eluser]
As Bart Mebane said check if url helper is autoloaded, then in the header file change

Code:
&lt;link rel="stylesheet" href="&lt;?php echo base_url()?&gt;images/Outdoor.css" type="text/css" /&gt;

to

Code:
&lt;link rel="stylesheet" href="&lt;?php echo base_url(); ?&gt;images/Outdoor.css" type="text/css" /&gt;

; is missing

Cristian Gilè
#4

[eluser]SPeed_FANat1c[/eluser]
Thank you guys Smile I forget to autoload url helper.

@cristian Gilè - it works now even without ; after base_url()




Theme © iAndrew 2016 - Forum software by © MyBB