Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在smarty codeigniter中设置多主题配置_Php_Codeigniter_Smarty - Fatal编程技术网

Php 在smarty codeigniter中设置多主题配置

Php 在smarty codeigniter中设置多主题配置,php,codeigniter,smarty,Php,Codeigniter,Smarty,我已经按照本手册设置了集成smarty和codeigniter环境 http://www.coolphptools.com/codeigniter-smarty 但我想使用smarty设置多主题。我知道它必须与我的库smarty.php 这是我的smarty.php文件 <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); /** * Smarty Class * * @pack

我已经按照本手册设置了集成smarty和codeigniter环境

http://www.coolphptools.com/codeigniter-smarty
但我想使用smarty设置多主题。我知道它必须与我的库
smarty.php

这是我的
smarty.php
文件

    <?php  if (!defined('BASEPATH')) exit('No direct script access allowed');

/**
 * Smarty Class
 *
 * @package     CodeIgniter
 * @subpackage  Libraries
 * @category    Smarty
 * @author      Kepler Gelotte
 * @link        http://www.coolphptools.com/codeigniter-smarty
 */
require_once( 'libs/Smarty-3.1.16/libs/Smarty.class.php' );

class CI_Smarty extends Smarty {

    function CI_Smarty()
    {
        parent::Smarty();

        $this->compile_dir = APPPATH . "views/templates_c";
        $this->template_dir = APPPATH . "views/templates";
        $this->assign( 'APPPATH', APPPATH );
        $this->assign( 'BASEPATH', BASEPATH );

        log_message('debug', "Smarty Class Initialized");
    }

    function __construct()
    {
        parent::__construct();

        $this->compile_dir = APPPATH . "views/templates_c";
        $this->template_dir = APPPATH . "views/templates";
        $this->assign( 'APPPATH', APPPATH );
        $this->assign( 'BASEPATH', BASEPATH );

        // Assign CodeIgniter object by reference to CI
        if ( method_exists( $this, 'assignByRef') )
        {
            $ci =& get_instance();
            $this->assignByRef("ci", $ci);
        }

        log_message('debug', "Smarty Class Initialized");
    }


    /**
     *  Parse a template using the Smarty engine
     *
     * This is a convenience method that combines assign() and
     * display() into one step. 
     *
     * Values to assign are passed in an associative array of
     * name => value pairs.
     *
     * If the output is to be returned as a string to the caller
     * instead of being output, pass true as the third parameter.
     *
     * @access  public
     * @param   string
     * @param   array
     * @param   bool
     * @return  string
     */
    function view($template, $data = array(), $return = FALSE)
    {
        foreach ($data as $key => $val)
        {
            $this->assign($key, $val);
        }

        if ($return == FALSE)
        {
            $CI =& get_instance();
            if (method_exists( $CI->output, 'set_output' ))
            {
                $CI->output->set_output( $this->fetch($template) );
            }
            else
            {
                $CI->output->final_output = $this->fetch($template);
            }
            return;
        }
        else
        {
            return $this->fetch($template);
        }
    }
}
// END Smarty Class

问题已解决,感谢github上的某个人

https://github.com/Vheissu/Ci-Smarty

必须仔细阅读代码,因为没有关于如何实现它的文档,我花了一些时间才理解。

为什么要使用Smarty?有什么好处?我只是想学习smarty。但我不想错过MVC部分,所以我尝试了smarty和codeigniter。。为什么不使用smarty?我是第一次用它,到目前为止我很喜欢它。。使很多工作更容易,我喜欢它的模板继承。好主意。不管怎么说,我的问题解决了,看到有人贴了一个代码,就不得不检查他的代码。看到我的答案了吗