首页 > 代码库 > PHPCMS常见问题
PHPCMS常见问题
(1)调用会员头像:
{get_memberavatar($r[‘userid‘],1,45)}
只要能够调用到userid,那么这段代码在哪里都可以使用:首页、栏目页、文章页。
这里我就用get来调用member表里面的userid字段。
/*这里就可以获取到userid*/{pc:get sql="select * from v9_member order by regdate desc" num="6"} {loop $data $r} <img src="http://www.mamicode.com/{get_memberavatar($r[userid],1,90)}" width="55" height="55" alt="{$r[username]}" target="_blank" /> {/loop}{/pc}
(2)phpcms分页样式及前台调用:
分页样式:
?/* 分页样式,直接放置在css文件中加载即可*/#pages { padding:14px 0 10px; font-family:宋体 }#pages a { display:inline-block; height:22px; line-height:22px; background:#fff; border:1px solid #e3e3e3; text-align:center; color:#333; padding:0 10px}#pages a.a1 { background:url(../images/admin_img/pages.png) no-repeat 0 5px; width:56px; padding:0 }#pages a:hover { background:#f1f1f1; color:#000; text-decoration:none }#pages span { display:inline-block; height:22px; line-height:22px; background:#5a85b2; border:1px solid #5a85b2; color:#fff; text-align:center;padding:0 10px}.page .noPage { display:inline-block; width:56px; height:22px; line-height:22px; background:url(../img/icu/titleBg.png) repeat-x 0 -55px ; border:1px solid #e3e3e3; text-align:center; color:#a4a4a4; }
前台调用分页:
?<!--分页前台调用--><div id="pages" style="margin-top:20px; text-align: center;"> {$pages}</div>
(3)前台调用全站搜索代码:
?<form action="index.php?m=search&c=index&a=init" method="get" target="_blank"> <input type="hidden" name="m" value="http://www.mamicode.com/search"/> <input type="hidden" name="c" value="http://www.mamicode.com/index"/> <input type="hidden" name="a" value="http://www.mamicode.com/init"/> <input type="hidden" name="typeid" value="http://www.mamicode.com/1" id="typeid"/> <input type="hidden" name="siteid" value="http://www.mamicode.com/1" id="siteid"/> <input name="q" id="q" type="text" value="http://www.mamicode.com/请输入……"/> <input name="submit"type="image" value="" /></form>
(4)前台评论框调用代码:
?<iframe src="http://www.mamicode.com/{APP_PATH}index.php?m=comment&c=index&a=init&commentid={id_encode("content_$catid",$id,$siteid)}&iframe=1" width="100%" height="100%" id="comment_iframe" frameborder="0" scrolling="no"></iframe>
(5)文章内容页显示点击数量:
需要用到jQuery:
?<script type="text/javascript" src="http://www.mamicode.com/{JS_PATH}jquery.min.js"></script>
需放在页面底部:
?<script language="JavaScript" src="http://www.mamicode.com/{APP_PATH}api.php?op=count&id={$id}&modelid={$modelid}"></script>
具体的数量值在span里面:
?<span id="hits"></span>
(6)详情页调用上一篇下一篇:
方法一:
?<div class="info"> <span>上一篇:<a href="http://www.mamicode.com/{$previous_page[url]}">{$previous_page[title]}</a></span> <span>下一篇:<a href="http://www.mamicode.com/{$next_page[url]}">{$next_page[title]}</a></span></div>
方法二:
?/*上一篇:*/ {pc:get sql="SELECT * FROM v9_news WHERE id < $id ORDER BY id DESC" num="1" return="p"}{loop $p $pv} {php $pid = "id = $pv[id]"}{pc:content action="lists" catid="$catid" where="$pid" order="id DESC" num="1"} <ul> {loop $data $key $val} <li> <a href="http://www.mamicode.com/{$val[‘url‘]}">{$val[‘title‘]}</a></li> {/loop} </ul> {/pc}{/loop}{/pc}
?/*下一篇:*/ {pc:get sql="SELECT * FROM v9_news WHERE id > $id ORDER BY id ASC" num="1" return="ne"}{loop $ne $nev} {php $neid = "id = $nev[id]"} {pc:content action="lists" catid="$catid" where="$neid" order="id DESC" num="1"} <ul> {loop $data $key $val} <li> <a href="http://www.mamicode.com/{$val[‘url‘]}">{$val[‘title‘]}</a></li> {/loop} </ul> {/pc} {/loop}{/pc}
(7)调用相关文章
{pc:content action=”relation” relation=”$relation” catid=”$catid” num=”5″ keywords=”$rs[keywords]“}{loop $data $r} <li><a href=http://www.mamicode.com/”{$r[url]}” target=”_blank”>{$r[title]}({date(‘Y-m-d’,$r[inputtime])})>
PHPCMS常见问题
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。