zoukankan      html  css  js  c++  java
  • dedecms5.7的文章详情页页面标题加载指定txt文本的随机关键字

    dedecms5.7的文章详情页加载指定txt文本的随机关键字

    1 实现代码如下

    {dede:name runphp='yes'}
          $file_path = "../test.txt";
          $file_arr = file($file_path);
          for($j=0;$j<count($file_arr);$j++){//逐行读取文件内容
              $tmpAry[$j]=explode(' ',$file_arr[$j]);
          }
          $aa=array_slice($tmpAry,0,count($file_arr));
          $bb=array();
          foreach($aa as $k=>$v) {
              $bb[]=trim($v[0]);
          }
         $key=array_rand($bb,3);
         $str = $bb[$key[0]].','.$bb[$key[1]].','.$bb[$key[2]];
         @me = $str;
         {/dede:name}

    2 在网站根目录  新建test.txt 格式如下

    标签1
    标签2
    标签3
    标签4
    标签5
    标签6
    标签7
    标签8
    标签9
    标签10

    3  代码放在哪里

    templatesdefaultarticle_article.htm的第5行  我是放在{dede:field.title/}的后面

    那么第5行的 title那行的代码如下

    <title>{dede:field.title/}_{dede:name runphp='yes'}
          $file_path = "../test.txt";
          $file_arr = file($file_path);
          for($j=0;$j<count($file_arr);$j++){//逐行读取文件内容
              $tmpAry[$j]=explode(' ',$file_arr[$j]);
          }
          $aa=array_slice($tmpAry,0,count($file_arr));
          $bb=array();
          foreach($aa as $k=>$v) {
              $bb[]=trim($v[0]);
          }
         $key=array_rand($bb,3);
         $str = $bb[$key[0]].','.$bb[$key[1]].','.$bb[$key[2]];
         @me = $str;
         {/dede:name}_{dede:global.cfg_webname/}</title>

    4 看下效果

  • 相关阅读:
    firewall
    mtu测试
    bps和pps
    PC上装VM上装虚拟机
    jira添加工作流
    【Linux系列】Centos 7安装 PHP(四)
    【Linux系列】Centos 7安装 Nginx(三)
    【Linux系列】配置Centos 7的软件源(二)
    【Linux系列】Centos 7安装以及网络配置(一)
    Python3获取豆瓣图书标签的前20本热门书籍(一)
  • 原文地址:https://www.cnblogs.com/baker95935/p/11685755.html
Copyright © 2011-2022 走看看