zoukankan      html  css  js  c++  java
  • 织梦正则自定义输出电脑站移动站上一篇下一篇文章

    不去修改程序文件,用标签和正则直接在内容页模板里直接输出上一篇下一篇的链接和标题和没有上一篇下一篇的提示文字

    电脑站上一篇下一篇的链接

    <li>
    <a href="{dede:prenext get=pre runphp=yes}$url = @me;preg_match('/href=['"]?([^'"]+)/', $url, $match);@me = $match[1];{/dede:prenext}">上一篇</a>
    </li>
    <li>
    <a href="{dede:prenext get=next runphp=yes}$url = @me;preg_match('/href=['"]?([^'"]+)/', $url, $match);@me = $match[1];{/dede:prenext}">下一篇</a>
    </li>

    电脑站上一篇下一篇的链接和标题和没有上一篇下一篇的提示文字

    {dede:prenext get=pre runphp=yes}
    $str = @me;
    $pattern = "/href=['"](.+?)['"]?>(.+?)</a>/";
    preg_match_all($pattern,$str, $match);
    @me = isset($match[1][0]) ? "<a href='{$match[1][0]}' title='{$match[2][0]}' class='l'><label class='a'>&lt;</label>上一篇</a>" : "没有上一篇了";
    {/dede:prenext}
    
    {dede:prenext get=next runphp=yes}
    $str = @me;
    $pattern = "/href=['"](.+?)['"]?>(.+?)</a>/";
    preg_match_all($pattern,$str, $match);
    @me = isset($match[1][0]) ? "<a href='{$match[1][0]}' title='{$match[2][0]}' class='r'>下一篇<label class='b'>&gt;</label></a>" : "没有下一篇了";
    {/dede:prenext}

    移动站上一篇下一篇的链接和标题和没有上一篇下一篇的提示文字

    <li>
    {dede:prenext get=pre runphp=yes}
    $preurl = @me;
    preg_match('/aid=(d*)/',$preurl,$match);
    $result = GetOneArchive($match[1]);
    @me = !empty($result) ? "上一篇:<a href="/m{$result['arcurl']}">{$result['title']}</a>" : "上一篇:没有了";
    {/dede:prenext}
    </li>
    <li>
    {dede:prenext get=next runphp=yes}
    $preurl = @me;
    preg_match('/aid=(d*)/',$preurl,$match);
    $result = GetOneArchive($match[1]);
    @me = !empty($result) ? "下一篇:<a href="/m{$result['arcurl']}">{$result['title']}</a>" : "下一篇:没有了";
    {/dede:prenext}
    </li>
  • 相关阅读:
    初试 spring web mvc
    读取网络数据缓存在本地 流程图
    servlet 过滤器实现 请求转发(跳转);跨域转发请求;tomcat 环境下。
    C# .net基于Http实现web server(web服务)
    微信公众平台开发
    Linux目录结构及作用
    MySQL事件调度器event的使用
    MySQL触发器trigger的使用
    存储过程的查、改、删
    MySQL游标的简单实践
  • 原文地址:https://www.cnblogs.com/dedehtml/p/9904712.html
Copyright © 2011-2022 走看看