2013-02-20 108 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>)生成的絕對路徑。檢查是否是這種情況。