Я работаю над системой CodeIgniter
с расширением Grocery_CRUD
. Я пытаюсь интегрировать систему входа в систему с CRUD-приложением.Выходная переменная не установлена CodeIgniter
В настоящее время я получаю эту ошибку, когда пользователь входит в систему, где должны быть отображены в приложение CRUD:
Серьезность: Обратите внимание сообщение: Undefined переменной: выход Имя файла: Views/members_area.php Номер строки : 13
Это линия ошибка встречающийся на: <?php echo $output; ?>
Я понимаю, что $output
не быть установлен, но я не могу понять, почему! ! Есть идеи?
Это весь мой файл members_area.php: Просмотр
<?php
echo '<span class="italic">'.date("l, F d, Y " ,time()).'</span>';
echo '<h3>Welcome: '.$this->session->userdata('username').' '. anchor('logout/signout', 'logout').'</h3>';
?>
<a href='<?php echo site_url('site/dishes_management')?>'>Dishes</a> |
<a href='<?php echo site_url('site/orders_management')?>'>Orders</a>
<?php echo $output; ?>
Это мой файл site.php: Контроллер
<?php
class Site extends CI_Controller{
function __construct(){
parent::__construct();
$this->is_logged_in();
$this->load->database();
$this->load->helper('url');
$this->load->library('grocery_CRUD');
}
function members_area($output = null){
$this->load->view('members_area', $output);
}
function is_logged_in(){
$is_logged_in = $this->session->userdata('is_logged_in');
if(!isset($is_logged_in) || $is_logged_in != true){
echo 'You need to login to access this page. <a href="../login">Login</a>';
die();
}
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->members_area($output);
}catch(Exception $e){
show_error($e->getMessage().' --- '.$e->getTraceAsString());
}
}
function orders_management()
{
$crud = new grocery_CRUD();
$crud->set_relation('customerNumber','customers','{contactLastName} {contactFirstName}');
$crud->display_as('customerNumber','Customer');
$crud->set_table('orders');
$crud->set_subject('Order');
$crud->unset_add();
$crud->unset_delete();
$output = $crud->render();
$this->members_area($output);
}
}
}
?>
По умолчанию я хотел бы, чтобы members_area.php
выход настроен на отображение предметы из таблицы блюд. Кажется, это не работает.
Любая помощь, как всегда высоко ценится!
Это действительно странно. Вы можете проверить, что показывают print_r и die для $ output = $ crud-> render(); , Например: print_r ($ output); умереть; Если у вас все еще есть проблемы, попробуйте начать с нуля с http://www.grocerycrud.com/documentation/create-crud-codeigniter-tutorial. Не могли бы вы рассказать мне, какую версию вы используете? –