0

用户登录到我的系统后,我很难让页面正确显示。我编写的大部分代码都取自教程,并根据我的需要进行了调整,这就是我遇到问题的原因!我想dishes_management()index(). 但是,如果我这样做,页面的样式就会完全扭曲。

如果我只是正常加载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());
    }
}

例子.php

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


4

1 回答 1

0

我不知道如何对原始问题发表评论,所以我暂时将其作为答案。如果这违反了任何 Stack Overflow 政策,请继续删除它。

如果一个页面的样式被破坏了,很可能是css链接标签的路径是相对路径,而不是生成的绝对路径site_url(<some_path>)。检查是否是这种情况。

于 2013-02-20T06:09:15.493 回答