gpt4 book ai didi

php - 如何在仪表板中加载模块的变量

转载 作者:行者123 更新时间:2023-11-29 00:31:07 25 4
gpt4 key购买 nike

我正在使用 pyroCMS 并且我有模块 A,因为我有一个 Controller ,我在 $var 中获取一些值,这些值是我在函数 index() 中定义的,如何在不同的模块中加载 Controller ,我必须在我的仪表板 View 中使用 Controller 中的变量

这是我在模块A中的 Controller 代码

public function index()
{
$data = $this->recent();
}

dashboard.php 查看文件

<div class="accordion-body collapse in lst" style="overflow: auto;">
<?php print_r($data );?>
</div>
I am not getting $data in dashboard.php

最佳答案

根据documentation ,它应该是这样的:

public function index()
{
$data = $this->recent();
$this->template
->set('data', $data)
->build('dashboard');
}

编辑:

要在用户访问仪表板时让模块加载数据,您需要使用 events .加载仪表板时应调用以下 Hook 。

Events::register('admin_controller', array($this, 'run'));

关于php - 如何在仪表板中加载模块的变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16461571/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com