Warm tip: This article is reproduced from serverfault.com, please click

php-在Codeigniter中,如何使库等待渲染视图

(php - In Codeigniter how to make library wait until view is rendered)

发布于 2020-12-02 03:05:57

我想在由自定义类库触发时显示一个模式,但不从外部显式调用其任何方法。

我将不得不等到视图模板被加载。

如何使我的库的方法等到加载视图?

第一步,我已经将库添加到自动加载数组中。

Questioner
Zurupupz
Viewed
11
Dum 2020-12-02 22:05:10

你尝试过挂钩吗?以下操作可能有效,但不确定。没有尝试自己。

$hook['post_controller'] = array(
        'class'    => 'MyClass',
        'function' => 'Myfunction',
        'filename' => 'Myclass.php',
        'filepath' => 'hooks',
        'params'   => array('beer', 'wine', 'snacks')
);

参考-https: //codeigniter.com/userguide3/general/hooks.html