首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >带phil surgeons模板的杂货crud

带phil surgeons模板的杂货crud
EN

Stack Overflow用户
提问于 2013-11-03 00:54:07
回答 1查看 1.3K关注 0票数 0

hii我有一个问题,如何在phils模板库中使用杂货crud这里是我的代码控制器

代码语言:javascript
运行
复制
public function user_management() { 
    $crud = new grocery_CRUD(); 
    $crud->set_subject('User'); 
    $output = $crud->render(); 
    $this->template->set_layout('blog');
    $this->template->set('output', $output); 
    $this->template->title('home', 'Grocery-Crud'); 
    $this->template->build('grocery'); 
}

这是我的观点

代码语言:javascript
运行
复制
<?php foreach($css_files as $file): ?>
<?php endforeach; ?> 
<?php foreach($js_files as $file): ?> 
<?php endforeach; ?>
<?php echo $output; ?>

我收到的错误信息如下

代码语言:javascript
运行
复制
 A PHP Error was encountered Severity: Notice Message: Undefined variable: css_files Filename: views/grocery.php Line Number: 2 A PHP Error was encountered Severity: Warning Message: Invalid argument supplied for foreach() Filename: views/grocery.php Line Number: 2 A PHP Error was encountered Severity: Notice Message: Undefined variable: js_files Filename: views/grocery.php Line Number: 5 A PHP Error was encountered Severity: Warning Message: Invalid argument supplied for foreach() Filename: views/grocery.php Line Number: 5 A PHP Error was encountered Severity: 4096 Message: Object of class stdClass could not be converted to string Filename: views/grocery.php Line Number: 10

请帮帮忙

EN

回答 1

Stack Overflow用户

发布于 2013-11-03 03:10:46

控制器

代码语言:javascript
运行
复制
  public function user_management() {
$crud = new grocery_CRUD();
$crud->set_table('user');
$crud->set_subject('User');
$output = $crud->render();
$this->template->set_layout('blog');
$this->template->set('output', (array) $output);
$this->template->title('home', 'Grocery-Crud');
$this->template->build('grocery');
}

在视图中

代码语言:javascript
运行
复制
<?php 
foreach($output['css_files'] as $file): ?>
<link type="text/css" rel="stylesheet" href="<?php echo $file; ?>" />
<?php endforeach; ?>
<?php foreach($output['js_files'] as $file): ?>
<script src="<?php echo $file; ?>"></script>
<?php endforeach; ?>

<div>
    <?php echo $output['output']; ?>
</div>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19744367

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档