个人常用代码备份
<!-- 1.头部通用 -->
<title>{if isset($seo_title)}{$seo_title}{else}{$siteconfigs['sitename']}{/if}</title>
<meta name="keywords" content="{if isset($seo_keywords)}{$seo_keywords}{/if}">
<meta name="description" content="{if isset($seo_description)}{$seo_description}{/if}">
<!-- 2.静态资源 -->
<link href="{R}t3/css/bootstrap.css" rel="stylesheet">
<!-- 3.遍历栏目 -->
<ul class="nav navbar-nav">
{wz:content action="category" pagesize="100" order="sort ASC"}
{loop $rs $r}
{if $r['pid']==0 && $r['ismenu']}
<li {if $r['cid'] == $cid || $r['cid'] == $categorys[$cid]['pid']}class="current"{/if}><a href="{$r['url']}">{$r['name']}</a></li>
{/if}
{/loop}
{/wz}
</ul>
<!-- web url -->
{WEBURL} $siteconfigs['sitename']
<!-- 模板调用 -->
{T "content", "head", TPLID}
<!-- 面包屑导航 -->
{catpos($cid)}
<!-- 字符串截取 -->
{strcut($r['remark'],200,'...')}
<!-- 栏目名称 -->
{$category['name']}
<!-- 分页 -->
{if $this->db->number>10}
<nav style="text-align: center;">
<ul class="pagination">
{$pages}
</ul>
</nav>
{/if}
<!-- 获取配置项 -->
$filterurl_config = get_config('filterurl_config','tuan');
<!-- 文章页 -->
<div class="text-center color_999">时间:{$addtime} {if $copyfrom!==""}来源:{/if}{$copyfrom} 访问次数:<span id="hits">0</span></div>
<!-- 浏览排行榜 -->
{wz:content action="rank" pagesize="10" order="weekviews DESC" cid="$cid" urlrule="$urlrule"}
{loop $rs $r}
<li ><a href="{$r[url]}">{$r['title']}</a></li>
{/loop}
{/wz}
<!-- 栏目页 -->
{$category['url']} {$category['name']}
{loop $sub_categorys $cats}
<li><a href="{$cats['url']}">{$cats['name']}</a></li>
{/loop}
<!-- 图片截取 -->
{imagecut($r['thumb'],273,380,4)}
<!-- 列表图片 -->
<img src="{if empty($r['thumb'])}{$siteconfigs['logo']}{else}{$r['thumb']}{/if}" />
<!-- 全局变量的读取 -->
{$siteconfigs['info_400']}
<!-- 查看当前页面所有的可用变量 -->
get_defined_vars()
<!-- 栏目相关信息 -->
$categorys $categorys['pid']['url']
<!-- 子栏目获取父栏目的名称 -->
$categorys[$category['pid']]['name']
<!-- 父栏目相关内容 -->
$top_category $top_categoryid
<!-- 数组中最后一项 栏目里最后一个栏目-->
$rs[count($rs)-1]['url']
<!-- 读取列表 -->
{wz:content action="listing" page="$page" pagesize="5" order="sort DESC,id DESC" cid="$cid" urlrule="$urlrule"}
{loop $rs $r}
{safe_htm($r['title'])}
{safe_htm($r['remark'])}.
{/loop}
{/wz}
<!-- 友情链接 -->
{wz:link action="listing" kid="0" pagesize="4" order="sort ASC"}
{loop $rs $r}
{$r['sitename']}
{/loop}
{/wz}
<!-- 上一篇、下一篇 -->
<div>{if $previous_page['url']}<a href="{$previous_page['url']}">上一篇:{strcut($previous_page['title'],50)}</a>{/if}</div>
<div>{if $next_page['url']}<a href="{$next_page['url']}">下一篇:{strcut($next_page['title'],50)}</a>{/if}</div>
查看所有的变量
{php print_r(get_defined_vars());}
<!-- 循环指定的栏目页,及其子栏目 -->
{php $sub_categorys = sub_categorys(2);}
{loop $sub_categorys $k $v}
{if $r['ismenu']}
<li class="list">
<a class="title" href="{$v['url']}"><span></span>{$v['name']}</a>
{if $v['child']}
{php $subs = sub_categorys($k);}
<ul>
{loop $subs $val}
{if $val['ismenu']}
<li class="sublist"><a href="{$val['url']}">{$val['name']}</a></li>
{/if}
{/loop}
</ul>
{/if}
</li>
{/if}
{/loop}
<!-- 相关文章 -->
{php $keywords = implode(',',$keywords);}
{wz:content action="relation" cid="$cid" keywords="$keywords" pagesize="8" order="id ASC
{loop $res $r}
{/loop}
{/wz}
<!-- 推荐位 -->
{wz:content action="block" page="$page" type="1" pagesize="6" blockid="39" order="sort DESC,id DESC" urlrule="$urlrule"}
{loop $rs $r}
{$r['price']}
{/loop}
{/wz}
<!-- 导航条二级栏目 选中头部导航 -->
<li {if $r['cid'] == $cid || $r['cid'] == $categorys[$cid]['pid']}class="current"{/if}>
<!-- 首页导航选中 -->
<li {if !isset($cid)}class="current"{/if}><a href="{$sitelist[2]['url']}">首页</a></li>
<title>{if isset($seo_title)}{$seo_title}{else}{$siteconfigs['sitename']}{/if} - Powered by wuzhicms</title>
<meta name="keywords" content="{if isset($seo_keywords)}{$seo_keywords}{/if}">
<meta name="description" content="{if isset($seo_description)}{$seo_description}{/if}">
<script type="text/javascript">
var cookie_pre = "{COOKIE_PRE}";
var cookie_domain = '{COOKIE_DOMAIN}';
var cookie_path = '{COOKIE_PATH}';
var web_url = '{WEBURL}';
</script>
$siteconfigs包含:
网站名称: $siteconfigs['sitename']
统计代码: $siteconfigs['statcode']
全局变量也存储在 siteconfigs 变量里。
// 英文分页
{php $mypages = preg_replace ("/首页/", 'First', $pages)}
{php $mypages = preg_replace ("/末页/", 'Last', $mypages)}
{php $mypages = preg_replace ("/按住向左方向键 向前翻页/", '', $mypages)}
{php $mypages = preg_replace ("/按住向右方向键 向后翻页/", '', $mypages)}
{php $mypages = preg_replace ("/总数/", 'Count', $mypages)}
{$mypages}
<!-- 分页条数 -->
{if $this->db->number>10}
<nav style="text-align: center;">
<ul class="pagination">
{$pages}
</ul>
</nav>
{/if}
<!-- 文章统计 -->
<script type="text/javascript" src="{WEBURL}index.php?f=stat&id={$id}&cid={$cid}"></script>
<!-- banner 广告调用 -->
{wz:sql sql="select `file`,`subtitle` from my_promote where pid=31"}
{php $i=0;}
{loop $rs $r}
<div class="item {if $i=='0'}active{/if}">
<a {if $r['subtitle']} href="{$r['subtitle']}" {/if}>
<img src="{$r['file']}" alt="{$r['file']}">
<!-- <div class="carousel-caption">
</div> -->
</a>
</div>
{php $i=$i+1;}
{/loop}
{/wz}
// 面包屑导航 栏目页
{php $srt = ''; $str = catpos2($cid, $symbol=' > ', $target = '_self', $str); echo substr($str, 0, -5);}
<!-- 自定义筛选条件 -->
{php $where = "title != '".$title."' AND cid=".$cid;}
{wz:content action="listing" cid="$cid" pagesize="5" where="$where" page="$page" order="sort DESC, id DESC" urlrule="$urlrule"}
{loop $rs $r}
<!-- 含二级栏目的栏目调用 -->
{wz:content action="category" pagesize="100" order="sort ASC"}
{loop $rs $r}
{if $r['pid']==0 && $r['ismenu']}
{$r['name']}
{if $r['child']}
{loop $rs $rn}
{if $rn['pid']==$r['cid']}{$rn['name']}{/if}
{/loop}
{/if}
{/if}
{/loop}
{/wz}
<!-- 栏目获取thumb -->
修改content模块里的lib/category_all.php 里的cache_all方法增加代码:$tmp['thumb'] = $v['thumb'];
<!-- https apache 配置 -->
<VirtualHost *:443>
DocumentRoot /home/wwwroot/www.sh108yy.net/www
ServerName api.sh108yy.net
ServerAlias api.sh108yy.net
DirectoryIndex index.php index.html
<Directory "/home/wwwroot/www.sh108yy.net/www">
Options FollowSymLinks
AllowOverride all
Order allow,deny
Allow from all
</Directory>
SSLEngine On
SSLCertificateFile /usr/local/apache/cert/1536755104326.pem
SSLCertificateKeyFile /usr/local/apache/cert/1536755104326.key
SSLCertificateChainFile /usr/local/apache/cert/chain.pem
ErrorLog "/home/wwwlogs/www.sh108yy.net-error.log"
CustomLog "/home/wwwlogs/www.sh108yy.net.log" common
</VirtualHost>
<!-- .htaccess -->
RewriteEngine on
RewriteRule ^en/$ /index.php?siteid=2
RewriteRule ^en/list-([0-9]+)-([0-9]+)-([0-9]+).html index.php?v=listing&cid=$1&page=$2&siteid=2
RewriteRule ^en/show-([0-9]+)-([0-9]+)-([0-9]+).html index.php?v=show&cid=$1&id=$2&page=$3&siteid=2
RewriteRule ^item-([0-9]+)-([0-9]+)-([0-9]+).html index.php?v=show&cid=$1&id=$2&page=$3
RewriteRule ^show-([0-9]+)-([0-9]+)-([0-9]+).html index.php?v=show&cid=$1&id=$2&page=$3
RewriteRule ^list-([0-9]+)-([0-9]+).html index.php?v=listing&cid=$1&page=$2
<!-- rewrite 规则里传递 get 参数 -->
RewriteRule ^globocare/list-([0-9]+)-([0-9]+).html index.php?v=listing&cid=$1&page=$2&%{QUERY_STRING}
<!-- ngnix的配置 -->
rewrite ^en$ index.php?siteid=2;
rewrite ^en/$ index.php?siteid=2;
rewrite ^en/list-([0-9]+)-([0-9]+).html index.php?v=listing&cid=$1&page=$2&siteid=2;
rewrite ^en/show-([0-9]+)-([0-9]+)-([0-9]+).html index.php?v=show&cid=$1&id=$2&page=$3&siteid=2;
rewrite ^item-([0-9]+)-([0-9]+)-([0-9]+).html index.php?v=show&cid=$1&id=$2&page=$3;
rewrite ^show-([0-9]+)-([0-9]+)-([0-9]+).html index.php?v=show&cid=$1&id=$2&page=$3;
rewrite ^list-([0-9]+)-([0-9]+).html index.php?v=listing&cid=$1&page=$2
批量替换
UPDATE 表名 SET
指定字段 = replace(指定字段, '要替换的字符串', '想要的字符串')
WHERE 条件;
--------------------------------------------------------------------
清空表数据
truncate table v9_kq_sh108yy_com 清空表中的数据
// 记录错误信息
error_log(date('Y-m-d H:i:s',SYS_TIME).' '.$sql."\r\n", 3, CACHE_ROOT."sql_log.".CACHE_EXT.'.sql');
{wz:sql sql="select * from sj_site where siteid=1 limit 1"}
{loop $rs $v}
{php $siteinfo = $v;}
{/loop}
{/wz}
{if $id}
<title>{$title}_{$siteinfo['name']}</title>
{elseif $cid}
<title>{if isset($seo_title)}{$seo_title}{else}{$categorys[$cid]['name']}{/if}_{$siteinfo['name']}</title>
{else}
<title>{if isset($seo_title)}{$seo_title}{else}{$siteconfigs['sitename']}{/if}</title>
{/if}
版权声明
本站部分原创文章,部分文章整理自网络。如有转载的文章侵犯了您的版权,请联系站长删除处理。如果您有优质文章,欢迎发稿给我们!联系站长:
愿本站的内容能为您的学习、工作带来绵薄之力。
评论