<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
require_once('smarty/smarty.class.php');
class Tp extends Smarty{
function tp(){
parent::Smarty();
$this->template_dir = APPPATH.'views';
$this->compile_dir = APPPATH.'templates_c/';
$this->left_delimiter = '<{';
$this->right_delimiter = '}>';
}
}
$autoload['libraries'] = array();
$autoload['libraries'] = array('database','tp');
<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Home extends CI_Controller {
function __construct()
{
parent::__construct();
$this->load->helper('url');
$this->tp->assign('base_url', base_url());
//定义css以及js的路径
}
function index()
{
$this->tp->assign("title","恭喜你smarty安装成功!");
$this->tp->assign("body","欢迎使用smarty模板引擎");
$arr = array(1=>'zhang',2=>'xing',3=>'wang');
$this->tp->assign("myarray",$arr);
$this->tp->display('ceshi.html');
}
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src='<!--{$base_url}-->js/jQuery.min.js' type='text/JavaScript' ></script>
<link href="<!--{$base_url}-->css/login.css" rel="stylesheet" type="text/css" />
<title>smarty安装测试</title>
</head>
<body>
<h1><{$title}></h1>
<p><{$body}></p>
<ul>
<{foreach from=$myarray item=v}>
<li><{$v}></li>
<{/foreach}>
</ul>
</body>
</html>
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有