Php 使用布局挂钩后,CodeIgniter Profiler不再显示
我刚刚设置了一个布局挂钩来简化我自己的一些工作,然而,我刚刚意识到我的分析器已经消失了。我不太清楚我需要做什么才能把它弄回来 如果我设置$config['enable_hooks']=FALSE,分析器会重新出现,但会破坏我的布局。我假设我必须为我的hook类添加一点,但我不确定现在在哪里或什么地方Php 使用布局挂钩后,CodeIgniter Profiler不再显示,php,codeigniter,Php,Codeigniter,我刚刚设置了一个布局挂钩来简化我自己的一些工作,然而,我刚刚意识到我的分析器已经消失了。我不太清楚我需要做什么才能把它弄回来 如果我设置$config['enable_hooks']=FALSE,分析器会重新出现,但会破坏我的布局。我假设我必须为我的hook类添加一点,但我不确定现在在哪里或什么地方 class Layout { public function index() { $CI =& get_instance(); $curre
class Layout {
public function index()
{
$CI =& get_instance();
$current_output = $CI->output->get_output();
if ($CI->uri->segment(1) == 'admin')
$layout_file = APPPATH . 'views/admin/layout.php';
else
$layout_file = APPPATH . 'views/frontend/layout.php';
$layout = $CI->load->file($layout_file, true);
$mod_output = str_replace("{yield}", $current_output, $layout);
//echo $layout_file;
echo $mod_output;
}
}
当然,我已经设置了$this->output->enable_profilerrue;在我的控制器里
如有任何建议或帮助,将不胜感激 探查器消失的原因是由输出对象在Output::\u display函数中运行探查器 正如前面所解释的,当您连接到display_覆盖点时,会阻止调用Output::_display 如果要在布局挂钩中输出探查器,则需要执行以下操作:
class Layout {
public function index()
{
$CI =& get_instance();
$current_output = $CI->output->get_output();
if ($CI->uri->segment(1) == 'admin')
$layout_file = APPPATH . 'views/admin/layout.php';
else
$layout_file = APPPATH . 'views/frontend/layout.php';
$layout = $CI->load->file($layout_file, true);
$mod_output = str_replace("{yield}", $current_output, $layout);
$CI->load->library('profiler');
if ( ! empty($CI->output->_profiler_sections))
{
$CI->profiler->set_sections($CI->output->_profiler_sections);
}
// If the output data contains closing </body> and </html> tags
// we will remove them and add them back after we insert the profile data
if (preg_match("|</body>.*?</html>|is", $output))
{
$mod_output = preg_replace("|</body>.*?</html>|is", '', $mod_output);
$mod_output .= $CI->profiler->run();
$mod_output .= '</body></html>';
}
else
{
$mod_output .= $CI->profiler->run();
}
//echo $layout_file;
echo $mod_output;
}
}
我所做的一切就是从输出中获取一块代码::\u display,用于呈现分析器输出并将其与钩子的其余部分一起插入