实例化页面代码
1.时间代码:{$vo.createtime|toDate=###,\'Y-m-d H:i:s\'}
2.连接:{:U(\'Pro/arr\')},{:URL()}
如:<form action="{:U(\'Pro/arr\')}" name="form" method="post">
打印出变量{php dump($r)}
截取字段{$r.title|str_cut=###,32}
时间{$r.createtime|toDate=###,\'Y-m-d\'}
包含文件<include file="Home:header"/> 对应文件Home_header.html
php页面中的连接
URL(\'Service-Pro/arr\') 如:$url = URL(\'Service-Pro/arr\').\'&p=\'; // 5.定义连接
{:U(\'Service-Pro/arr\')} //JS中的连接 如: url:"{:U(\'Service-Pro/arr\')}",
<a href="{:U(\'Client/edit\',array(id=>$ser[\'id\']))}">
输出模板指定:$this->display (\'edit\');
当前位置首页 > 新闻中心:<span>{:L(catpos)} <a href="{:URL()}">{:L(home_font)}</a> > <YP:catpos catid="catid" space=" > " /></span>
单页标签{$title} {$content} {$thumb}
提交跳转
$this->assign(\'jumpUrl\',U(\'Index/index\')); $this->success(L(\'login_ok\'));
form表单
action="{:U(\'index/check\')}" //对应的连接地址 /yt/index.php?g=Random&m=index&a=check
查询语句$where[\'status\']=\'1\';
$where[\'name\']=\'百度\'; $list = $m->where($where)->select(); 还有其他几中 1.$where = \'and status =1\'; 2.$where[\'status\']=\'1\'; 3.$list = $m->where(\'status=1\')->select(); 4.$where[\'title\'] = array(\'like\',\'%\'.$title.\'%\');
thinkphp参考 http://doc.thinkphp.cn/manual/query.html (非常实用网址)
自己写分页代码
public function arr(){ $m = M(\'problem\'); //0.基本条件 $pagesize = \'1\'; $p = $_GET[\'p\']; if(empty($_GET[\'title\'])){ $title = \'\'; }else{ $title = $_GET[\'title\']; } $where[\'title\'] = array(\'like\',\'%\'.$title.\'%\'); // 1.查询条件 $where[\'status\'] = \'1\'; $totalNum=$m->where($where)->count(); // 2.总几条数据 $totalpage = intval($totalNum/$pagesize); // 3.计算分页[共几页] $totalp = $totalNum%$pagesize; if($totalp !=0){ $totalpage +=1; } $nowpage = $p; // 4. 翻页分4个节点【当前页,上一页,下一页,尾页】 if($p<=1){ $nowpage = \'1\'; } $nowsize = $nowpage*$pagesize-$pagesize; // [当前条数] $firstpage = 1; $prevpage = $nowpage-1; //[上一页] if($prevpage<=$nowpage){ $prevpage = $nowpage; } $nextpage = $nowpage+1; //[下一页] if($nextpage>=$totalpage){ $nextpage = $totalpage; } $lastpage = $totalpage; //[尾页] $url = URL(\'Service-Pro/arr\').\'&title=\'.$title.\'&p=\'; // 5.定义连接 $page = \'<a class="a1">共\'.$totalNum.\'条 当前\'.$nowpage.\'/\'.$totalpage.\'页</a>\'; $page .= \'<a href="\'.$url.$firstpage.\'">第一页</a>\'; $page .= \'<a href="\'.$url.$prevpage.\'">上一页</a>\'; $page .= \'<a href="\'.$url.$nextpage.\'">下一页</a>\'; $page .= \'<a href="\'.$url.$lastpage.\'">尾页</a>\'; $list = $m->where($where)->limit($nowsize,$pagesize)->order(\'createtime desc\')->select(); $this->assign(\'ser_title\',$title); $this->assign(\'page\',$page); $this->assign(\'list\',$list); $this->display(); }
单页标签
{$title} {$content} {$thumb}
读取任意页面内容
<YP:list sql="select * from yp_page where id=21"> {$r.content|str_cut=###,200} </YP:list>
调取分页;控制分页条数(调用 设置条数 后台设置----》 系统参数 –》列表分页 控制条数 就可以了)
{$pages}
list标签
<YP:list order="id desc" catid="4" limit="6" posid="1" where=""> {php dump($r)} 可以打印出所有内容 </YP:list>
volist标签;读取指定文章、产品下列表
<volist name="list" id="r"> {$r.title} </volist>
YOURPHP执行sql语句
{php $sql=\'select * from yb_slide_data where fid=2\';}
<YP:list sql="$sql">
{$r.url} {$r.pic}
</YP:list>
这两个意思是一样的
<?php
$sql = \'select * from \';
$catid = \'5\'; //下面 <YP:list catid=\'$catid\'> 可以接收php 值
?>
<YP:list sql="$sql">
{$r.url} {$r.pic}
</YP:list>
友情链接
<YP:link typeid="2" linktype="2" > <li><a href="{$r[\'siteurl\']}" target="_blank" title="{$r[\'name\']}"><img src="{$r[\'logo\']}" alt="{$r[\'name\']}"></a></li> </YP:link> typeid="2" 为友情链接所有类别ID linktype="2" 设置调用什么类型的链接 1为文字链接.2为图片链接 id = "r" //定义数据查询的结果存放变量 key = "i" 返回数据主键变量名称 order = \'id desc\';排序方式 limit ="10" 调用条数 默认10条
读取子菜单
<YP:subcat catid="8"> <li><a href="{$r.url}">{$r.catname}</a></li> </YP:subcat> 参考手册:http://www.yourphp.cn/ebook/template/tag/show_59.html
上一篇,下一篇
<?php $pre = M(\'Article\')->where("id<$id and catid=$catid")->order("id DESC")->find(); echo M(\'Article\')->getLastSql(); $next = M(\'Article\')->where("id>$id and catid=$catid")->order("id ASC")->find(); ?>
html代码
{if $pre}<a href="{$pre[url]}">{$pre[title]}</a>{else}无{/if} {if $next}<a href="{$next[url]}">{$next[title]}</a>{else}无{/if}
文档关键字
{if $keywords}
<br><font color="red">{:L(\'KEYWORD\')}:<yp:tags moduleid="moduleid" keywords="keywords"><a href="{:TAGURL($r)}">{$r.name}</a> </yp:tags> </font>
<br>{:L(\'RELATED_ARTICLES\')}:
<br><yp:tags moduleid="2" keywords="keywords" list="1"><a href="{$r.url}">{$r.title}</a><br> </yp:tags> <br>
{/if}
读取列表的 1,2,3;加 key="key"
<volist name="list" id="r" key="key"> <dl>[{$key}]. <a href="{$cid[\'url\']}">{$r.title}</a> <span>[2014-01-09] 浏览:135次</span></dl> </volist>
if语句
{if $catid=="11"}9999{/if}
{if $copyfrom}{$copyfrom}{else}{$site_name}{/if}
<?php if($catid==1){ echo \'新闻\'; }elseif($catid==2){ echo \'产品\';}else{ echo \'其他\' }?>