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>
  • 相关阅读:
    java基础 类 & 继承
    java基础之 hashmap
    tomcat 详解
    hash算法
    素数
    『战略游戏 最大利润 树形DP』
    『宝藏 状态压缩DP NOIP2017』
    『玩具装箱TOY 斜率优化DP』
    『数组的最大代价 贪心优化DP』
    『最大M子段和 线性DP』
  • 原文地址:https://www.cnblogs.com/dedehtml/p/9904712.html
Copyright © 2011-2022 走看看