php - 如何在 custom_loader 中加载库?
问题描述
我试图弄清楚如何从位于 /application/core/SACC_Loader.php 的自定义加载器中加载会话、ftp 等库
到目前为止,我已经尝试了正常的方法,并使用 get_instance() 但无济于事。
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class SACC_Loader extends CI_Loader {
private $lang = null;
public function template($template_name, $vars = array(), $return = FALSE, $ajax = FALSE)
{
/* Prepare default values always loaded unless it's an Ajax request */
$vars = $this->static_content($vars);
if($return){
$content = $this->view('components/header', $vars, $return);
$content .= $this->view($template_name, $vars, $return);
$content .= $this->view('components/footer', $vars, $return);
return $content;
} else {
$this->view('components/header', $vars);
$this->view($template_name, $vars);
$this->view('components/footer', $vars);
}
}
还是我接近这一切都错了?我的想法是使用自定义加载器始终将所需数据携带到正在运行的任何控制器中,而不必在每个控制器中加载模型,因为我已经为所有页面使用了自定义加载器来加载模板,而不仅仅是单个/多个视图每个控制器方法。
我的意思是这行得通,但感觉是重复的。
解决方案
推荐阅读
- python - TypeError: unhashable type: 'numpy.ndarray' mnist
- google-cloud-platform - gcloud cloudshell ssh 不断退出 gcloud
- c - 文本文件的最后一行打印两次
- html - Bootstrap 3 具有相同高度和宽度的卡片 CSS HTML
- vb.net - 如何在 VB 表单中截取完整的屏幕截图
- firebase - 具有完整性的 NoSQL 关系
- r - 如何为我的每一行数据取平均值?
- csv - 使用单义性解析器加载大型 CSV 文件时过早的 EOF。
- c# - 如何根据需要更改文本的首字母和其余字母?
- r - 将多行与R中的相同条目结合起来