【phpcms-v9】phpcms-v9文章详情页评论

来源:互联网 发布:u盘重装mac 编辑:程序博客网 时间:2024/06/03 00:26

1.phpcms-v9中文章详情页的评论是以iframe方式内嵌入到show.html文件中的,而且只能以内嵌入的方式载入,因为文章可能有分页、评论可能也有分页,如果不适用iframe,当同时出现两个分页的话,就会出现问题

使用内嵌入还有一个好处:可以实现局部刷新,不用重新刷新整个文章页面

      {if $allow_comment && module_exists('comment')}          <iframe src="{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>      {/if}

2.注意:第二行代码,通过iframe方式载入
      {APP_PATH}index.php?m=comment&c=index&a=init

3.通过查看comment/index.php控制器中的init方法,得知默认载入的是templates/comment/show_list.html评论列表页模板文件

                if (isset($_GET['iframe'])) {if (strpos($url,APP_PATH) === 0) {$domain = APP_PATH;} else {$urls = parse_url($url);$domain = $urls['scheme'].'://'.$urls['host'].(isset($urls['port']) && !empty($urls['port']) ? ":".$urls['port'] : '').'/';}include template('comment', 'show_list');} else {include template('comment', 'list');}

4.show_list.html文件通过pc标签来循环显示评论内容:

{pc:comment action="lists" commentid="$commentid" siteid="$siteid" page="$_GET[page]" hot="$hot" num="6"}{if !empty($data)}      <div class="comment_button"><a href="{APP_PATH}index.php?m=comment&c=index&a=init&commentid={$commentid}&title={urlencode(($comment[title] ? $comment[title] : $title))}&url={urlencode(($comment[url] ? $comment[url] : $url))}&hot=0&iframe=1"{if empty($hot)} class="on"{/if}>最新</a> <a href="{APP_PATH}index.php?m=comment&c=index&a=init&commentid={$commentid}&title={urlencode(($comment[title] ? $comment[title] : $title))}&url={urlencode(($comment[url] ? $comment[url] : $url))}&hot=1&iframe=1"{if $hot} class="on"{/if}>最热</a></div>    <div class="comment">{loop $data $r}    <h5 class="title fn">{direction($r[direction])} <font color="#FF0000">{format::date($r[creat_at], 1)}</font> {if $r[userid]}{get_nickname($r[userid])}{else}{$r[username]}{/if} </h5>    <div class="content">{$r[content]}<div class="rt"><a href="javascript:void(0)" onclick="reply({$r[id]}, '{$commentid}')">回复</a>  <a href="javascript:void(0)" onclick="support({$r[id]}, '{$commentid}')">支持</a>(<font id="support_{$r[id]}">{$r[support]}</font>)</div><div id="reply_{$r[id]}" style="display:none"></div></div>  <div class="bk30 hr mb8"></div>  {/loop}</div> <div id="pages" class="text-r">{$pages}</div> {/if} {/pc}

5.效果如下:



原创粉丝点击