讯睿CMS内容页自定义评论列表调用

      发布在:后端技术      评论:0 条评论
<p>有的时候我们需要实现打开内容页直接定位到某天留言位置,所以就需要用的锚点的。</p><p>原来模版的写法<br/></p><pre style="background-color:#262e37;color:#ffffff;font-family:&#39;Consolas&#39;;font-size:11.3pt;"><span style="color:#5b7773;background-color:#191f26;">&lt;!--</span><span style="color:#5b7773;background-color:#191f26;font-family:&#39;宋体&#39;;">调用</span><span style="color:#5b7773;background-color:#191f26;">ajax</span><span style="color:#5b7773;background-color:#191f26;font-family:&#39;宋体&#39;;">评论</span><span style="color:#5b7773;background-color:#191f26;">--&gt;</span><span style="color:#5b7773;"><br/></span><span style="font-weight:bold;">{if IS_COMMENT}<br/></span><span style="font-weight:bold;">{dr_module_comment(MOD_DIR, $id)}<br/></span><span style="font-weight:bold;">{/if}</span></pre><p style="white-space: normal;">在此就需要对dr_module_comment评论函数进行自定义</p><pre style="background-color: rgb(38, 46, 55); color: rgb(255, 255, 255); font-family: Consolas; font-size: 11.3pt;"> <span style="color: rgb(91, 119, 115); background-color: rgb(25, 31, 38);">&lt;!--</span><span style="color: rgb(91, 119, 115); background-color: rgb(25, 31, 38); font-family: 宋体;">调用</span><span style="color: rgb(91, 119, 115); background-color: rgb(25, 31, 38);">ajax</span><span style="color: rgb(91, 119, 115); background-color: rgb(25, 31, 38); font-family: 宋体;">评论自定义模版调用方式</span><span style="color: rgb(91, 119, 115); background-color: rgb(25, 31, 38);">--&gt;</span><span style="color: rgb(91, 119, 115);"><br/></span><span style="color: rgb(91, 119, 115);"> &nbsp; &nbsp;</span><span style="font-weight: bold;">{if IS_COMMENT}<br/></span><span style="font-weight: bold;"> &nbsp; &nbsp;</span>&lt;<span style="color: rgb(195, 40, 103); font-weight: bold;">div </span><span style="color: rgb(166, 226, 46);">id</span><span style="color: rgb(230, 219, 116); font-weight: bold;">=&quot;dr_module_comment_{$id}&quot;</span>&gt;&lt;/<span style="color: rgb(195, 40, 103); font-weight: bold;">div</span>&gt;<br/> &lt;<span style="color: rgb(195, 40, 103); font-weight: bold;">script </span><span style="color: rgb(166, 226, 46);">type</span><span style="color: rgb(230, 219, 116); font-weight: bold;">=&quot;text/javascript&quot;</span>&gt;<br/> <span style="color: rgb(249, 38, 114);">function </span><span style="font-style: italic;">dr_ajax_module_comment_</span>{$id}(<span style="color: rgb(102, 14, 122); font-weight: bold; font-style: italic;">type</span>, page) {<br/> <span style="color: rgb(249, 38, 114);">var </span><span style="color: rgb(102, 14, 122); font-weight: bold; font-style: italic;">index </span><span style="color: rgb(249, 38, 114);">= </span><span style="color: rgb(102, 14, 122); font-weight: bold;">layer</span>.<span style="color: rgb(74, 198, 10);">load</span>(<span style="color: rgb(174, 129, 255);">2</span>, { <span style="color: rgb(102, 14, 122); font-weight: bold;">time</span><span style="color: rgb(249, 38, 114);">: </span><span style="color: rgb(174, 129, 255);">10000 </span>});<br/> <span style="font-style: italic;">$</span>.<span style="color: rgb(74, 198, 10);">ajax</span>({<span style="color: rgb(102, 14, 122); font-weight: bold;">type</span><span style="color: rgb(249, 38, 114);">: </span><span style="color: rgb(230, 219, 116);">&quot;GET&quot;</span>, <span style="color: rgb(102, 14, 122); font-weight: bold;">url</span><span style="color: rgb(249, 38, 114);">: </span><span style="color: rgb(230, 219, 116);">&quot;/index.php?s={MOD_DIR}&amp;c=comment&amp;m=index&amp;id={$id}&amp;type=&quot;</span><span style="color: rgb(249, 38, 114);">+</span><span style="color: rgb(102, 14, 122); font-weight: bold; font-style: italic;">type</span><span style="color: rgb(249, 38, 114);">+</span><span style="color: rgb(230, 219, 116);">&quot;&amp;page=&quot;</span><span style="color: rgb(249, 38, 114);">+</span>page<span style="color: rgb(249, 38, 114);">+</span><span style="color: rgb(230, 219, 116);">&quot;&amp;&quot;</span><span style="color: rgb(249, 38, 114);">+</span><span style="color: rgb(102, 14, 122); font-weight: bold; font-style: italic;">Math</span>.<span style="color: rgb(74, 198, 10);">random</span>(), <span style="color: rgb(102, 14, 122); font-weight: bold;">dataType</span><span style="color: rgb(249, 38, 114);">:</span><span style="color: rgb(230, 219, 116);">&quot;jsonp&quot;</span>,<br/> <span style="color: rgb(74, 198, 10);">success</span><span style="color: rgb(249, 38, 114);">: function </span>(<span style="color: rgb(253, 151, 31); font-style: italic;">data</span>) {<br/> <span style="color: rgb(102, 14, 122); font-weight: bold;">layer</span>.<span style="color: rgb(74, 198, 10);">close</span>(<span style="color: rgb(102, 14, 122); font-weight: bold; font-style: italic;">index</span>);<br/> <span style="color: rgb(249, 38, 114);">if </span>(<span style="color: rgb(253, 151, 31); font-style: italic;">data</span>.<span style="color: rgb(102, 14, 122); font-weight: bold;">code</span>) {<br/> <span style="font-style: italic;">$</span>(<span style="color: rgb(230, 219, 116);">&quot;#dr_module_comment_{$id}&quot;</span>).<span style="color: rgb(74, 198, 10);">html</span>(<span style="color: rgb(253, 151, 31); font-style: italic;">data</span>.<span style="color: rgb(74, 198, 10);">msg</span>);<br/> <span style="color: rgb(91, 119, 115); background-color: rgb(25, 31, 38);">//</span><span style="color: rgb(91, 119, 115); background-color: rgb(25, 31, 38); font-family: 宋体;">自定义新增滚动到指定评论位置</span><span style="color: rgb(91, 119, 115); font-family: 宋体;"><br/></span><span style="color: rgb(91, 119, 115); font-family: 宋体;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: rgb(249, 38, 114);">if</span>(<span style="font-style: italic;">$</span>(<span style="color: rgb(102, 14, 122); font-weight: bold; font-style: italic;">location</span>.<span style="color: rgb(102, 14, 122); font-weight: bold;">hash</span>).<span style="color: rgb(102, 14, 122); font-weight: bold;">length</span><span style="color: rgb(249, 38, 114);">&gt;</span><span style="color: rgb(174, 129, 255);">0</span>){<br/> <span style="color: rgb(102, 14, 122); font-weight: bold; font-style: italic;">console</span>.<span style="color: rgb(74, 198, 10);">log</span>(<span style="color: rgb(230, 219, 116);">&#39;$(location.hash).offset().top=&#39;</span>,<span style="font-style: italic;">$</span>(<span style="color: rgb(102, 14, 122); font-weight: bold; font-style: italic;">location</span>.<span style="color: rgb(102, 14, 122); font-weight: bold;">hash</span>).<span style="color: rgb(74, 198, 10);">offset</span>().<span style="color: rgb(74, 198, 10);">top</span>);<br/> <span style="font-style: italic;">$</span>(<span style="color: rgb(102, 14, 122); font-weight: bold; font-style: italic;">window</span>).<span style="color: rgb(102, 14, 122); font-weight: bold;">scrollTop</span>(<span style="font-style: italic;">parseInt</span>(<span style="font-style: italic;">$</span>(<span style="color: rgb(102, 14, 122); font-weight: bold; font-style: italic;">location</span>.<span style="color: rgb(102, 14, 122); font-weight: bold;">hash</span>).<span style="color: rgb(74, 198, 10);">offset</span>().<span style="color: rgb(74, 198, 10);">top</span>)<span style="color: rgb(249, 38, 114);">-</span><span style="color: rgb(174, 129, 255);">100</span>);<br/> }<br/> } <span style="color: rgb(249, 38, 114);">else </span>{<br/> <span style="font-style: italic;">dr_tips</span>(<span style="color: rgb(174, 129, 255);">0</span>, <span style="color: rgb(253, 151, 31); font-style: italic;">data</span>.<span style="color: rgb(74, 198, 10);">msg</span>);<br/> }<br/> },<br/> <span style="color: rgb(74, 198, 10);">error</span><span style="color: rgb(249, 38, 114);">: function</span>(<span style="color: rgb(253, 151, 31); font-style: italic;">HttpRequest</span>, <span style="color: rgb(253, 151, 31); font-style: italic;">ajaxOptions</span>, <span style="color: rgb(253, 151, 31); font-style: italic;">thrownError</span>) {<br/> <span style="color: rgb(102, 14, 122); font-weight: bold;">layer</span>.<span style="color: rgb(74, 198, 10);">closeAll</span>();<br/> <span style="font-style: italic;">alert</span>(<span style="color: rgb(230, 219, 116);">&quot;</span><span style="color: rgb(230, 219, 116); font-family: 宋体;">评论调用函数返回错误:</span><span style="color: rgb(230, 219, 116);">&quot;</span><span style="color: rgb(249, 38, 114);">+</span><span style="color: rgb(253, 151, 31); font-style: italic;">HttpRequest</span>.<span style="color: rgb(102, 14, 122); font-weight: bold;">responseText</span>);<br/> }<br/> });<br/> }<br/> <span style="font-style: italic;">dr_ajax_module_comment_</span>{$id}(<span style="color: rgb(174, 129, 255);">0</span>, <span style="color: rgb(174, 129, 255);">1</span>);<br/>&lt;/<span style="color: rgb(195, 40, 103); font-weight: bold;">script</span>&gt;<br/> <span style="font-weight: bold;">{/if}</span></pre><div><span style="font-weight: bold;"><br/></span></div><p><br/></p>
热门推荐