PHPCMS中在静态页面用iframe方式调用用户收藏夹
  • 分类:经验分享
  • 发表:2014-07-06
  • 围观(20,114)
  • 评论(0)

1、在调用位置增加代码:

<script type="text/javascript">document.write('<iframe src="{APP_PATH}index.php?m=content&c=index&a=server_favorite&forward='+encodeURIComponent(location.href)+'&siteid=1" allowTransparency="true" width="270" height="230" frameborder="0" scrolling="no"></iframe>')</script>

2、在\phpcms\modules\content\index.php文件结尾}前加上:

//用户收藏夹
public function server_favorite() {
$_username = param::get_cookie('_username');
$_userid = param::get_cookie('_userid');
include template('content', 'server_favorite');
}

3、在网站模板的content文件夹新建模板文件server_favorite.html,内容为:

<style type="text/css">
body{ margin: 0px; padding: 0px; font-size: 12px; line-height: 26px; color: #666666; }
a{ font-size: 12px; color: #666666; text-decoration: none; }
.favorite-list{ margin: 10px; padding: 0px; list-style-type: none; }
.favorite-list li{ float: left; height: 90px; width: 100px; border: 1px solid #DDD; text-align: center; padding: 5px; margin-right: 10px; margin-bottom: 10px; line-height: 26px; }
.favorite-list li.two{ margin-right:0px;}
.favorite-list li img{}
.message{ padding-top: 15px; padding-bottom: 15px; padding-left: 10px; }
</style>
{if $_userid}
{pc:member action="favoritelist" userid="$_userid" where="type='open'" order="id DESC" num="4"}
<ul class="favorite-list">
{if $data}
{loop $data $k $v}
<li {if $n%2==0}class="two"{/if}><a href="{$v['url']}" title="{$v['title']}" target="_blank"><img src="{thumb($v['thumb'],100,68)}" alt="{$v['title']}" />{str_cut($v['title'],20)}</a></li>
{/loop}
{else}
还没有收藏内容哦~
{/if}
</ul>
{/pc}
{else}
<DIV class="message">您还没有登陆<br />请<a href="/index.php?m=member&amp;c=index&amp;a=register&amp;siteid=1" target="_blank"><strong>注册</strong></a>或<a href="/index.php?m=member&amp;c=index&amp;a=login&amp;forward=http%3A%2F%2Fn.enlern.com%2F&amp;siteid=1" target="_blank"><strong>登陆</strong></a>网站后再使用收藏夹功能。</DIV>
{/if}

代码中的where="type='open'"和{thumb($v['thumb'],100,68)}是自己添加的字段,方法见http://www.nywzjs.com/?p=262

然后就结束了,,,如果只是在动态页面调用,可以参照http://www.nywzjs.com/?p=262,简单、直接,,

Top