2013-02-20 112 views
0

我很难在用户登录到我的系统后正确显示页面。我写的大部分代码都是从教程中获得的,并且适合我的需求,这就是为什么我遇到了问题!我想在index()内运行dishes_management()方法。但是,如果我这样做,页面的样式完全失真。CodeIgniter的布局错误

如果我正常加载index(),然后单击我的example.php视图中的其中一个链接,它将打开并完美显示!为什么是这样?

class Examples extends CI_Controller { 

function __construct() 
{ 
    parent::__construct(); 
    $this->load->database(); 
    $this->load->helper('url'); 
    $this->load->library('grocery_CRUD'); 
} 

function _example_output($output = null) 
{ 
    $this->load->view('example.php',$output); 

} 

function index() 
{ 
    $this->_example_output((object)array('output' => '' , 'js_files' => array() , 'css_files' => array())); 
} 

function dishes_management() 
{ 
    try{ 
     $crud = new grocery_CRUD(); 

     $crud->set_theme('datatables'); 
     $crud->set_table('dishes'); 
     $crud->set_subject('Dish'); 
     $crud->required_fields('dish_name'); 
     $crud->columns('dish_name','dish_desc','dish_price', 'dish_cat'); 

     $output = $crud->render(); 

     $this->_example_output($output); 

    }catch(Exception $e){ 
     show_error($e->getMessage().' --- '.$e->getTraceAsString()); 
    } 
} 

使用example.php

<a href='<?php echo site_url('examples/dishes_management')?>'>Dishes</a> | 
    <a href='<?php echo site_url('examples/orders_management')?>'>Orders</a> | 


+0

你是什么意思风格扭曲?样式表是否被加载?你有错误吗? – Jeemusu 2013-02-20 05:28:45

+0

我没有得到任何错误,样式表似乎被加载但不正确。 – Javacadabra 2013-02-20 13:29:51

回答

0

我不知道如何写在原来的问题发表意见,所以我会离开它作为一个答案现在。如果这违反了Stack Overflow策略,请继续并删除它。

如果页面样式被破坏,那么css链接标记的路径最有可能是相对路径,而不是由site_url(<some_path>)生成的绝对路径。检查是否是这种情况。