<p>有的时候我们需要实现打开内容页直接定位到某天留言位置,所以就需要用的锚点的。</p><p>原来模版的写法<br/></p><pre style="background-color:#262e37;color:#ffffff;font-family:'Consolas';font-size:11.3pt;"><span style="color:#5b7773;background-color:#191f26;"><!--</span><span style="color:#5b7773;background-color:#191f26;font-family:'宋体';">调用</span><span style="color:#5b7773;background-color:#191f26;">ajax</span><span style="color:#5b7773;background-color:#191f26;font-family:'宋体';">评论</span><span style="color:#5b7773;background-color:#191f26;">--></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);"><!--</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);">--></span><span style="color: rgb(91, 119, 115);"><br/></span><span style="color: rgb(91, 119, 115);"> </span><span style="font-weight: bold;">{if IS_COMMENT}<br/></span><span style="font-weight: bold;"> </span><<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;">="dr_module_comment_{$id}"</span>></<span style="color: rgb(195, 40, 103); font-weight: bold;">div</span>><br/> <<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;">="text/javascript"</span>><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);">"GET"</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);">"/index.php?s={MOD_DIR}&c=comment&m=index&id={$id}&type="</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);">"&page="</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);">"&"</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);">"jsonp"</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);">"#dr_module_comment_{$id}"</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: 宋体;"> </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);">></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);">'$(location.hash).offset().top='</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);">"</span><span style="color: rgb(230, 219, 116); font-family: 宋体;">评论调用函数返回错误:</span><span style="color: rgb(230, 219, 116);">"</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/></<span style="color: rgb(195, 40, 103); font-weight: bold;">script</span>><br/> <span style="font-weight: bold;">{/if}</span></pre><div><span style="font-weight: bold;"><br/></span></div><p><br/></p>
讯睿CMS模版中自定义阅读量数据的调用写法
讯睿CMS首页模版调用分页及分页数写法,在这里还是使用的module循环调用的。
实现related讯睿CMS内容页关联调用排除当前文章信息
讯睿CMS实现仿wordpress博客框架按时间归档信息展示
有的时候使用讯睿CMS做网站的时候需要获取会员上次登陆时间,分析框架发现了dr_member_login表用于记录会员登录时间,于是调用最近一次登录记录即可。
实现讯睿cms根据后台是否设置快捷登陆API密钥等信息来决定展示快捷登陆按钮