zoukankan      html  css  js  c++  java
  • ecshop如何让所有页面都显视最能文章以提高SEO优化效果

    在程序根目录找到文件index.php 打开,找下面的代码,剪切。

    $smarty->assign('new_articles',    index_get_new_articles());   // 最新文章
    

     再在程序根目录打开文件 includes/init.php

    找到代码:

    $smarty->assign('lang', $_LANG);

     在这条代码下,粘贴刚才剪切的那条代码。

    再打开程序根目录下的文件 index.php 找到下面的代码剪切。

    /**
    * 获得最新的文章列表。
    *
    * @access private
    * @return array
    */
    function index_get_new_articles()
    {
    $sql = 'SELECT a.article_id, a.title, ac.cat_name, a.add_time, a.file_url, a.open_type, ac.cat_id, ac.cat_name ' .
    ' FROM ' . $GLOBALS['ecs']->table('article') . ' AS a, ' .
    $GLOBALS['ecs']->table('article_cat') . ' AS ac' .
    ' WHERE a.is_open = 1 AND a.cat_id=13 AND a.cat_id = ac.cat_id AND ac.cat_type = 1' .
    ' ORDER BY a.article_type DESC, a.add_time DESC LIMIT ' . $GLOBALS['_CFG']['article_number'];
    $res = $GLOBALS['db']->getAll($sql);
    
    $arr = array();
    foreach ($res AS $idx => $row)
    {
    $arr[$idx]['id'] = $row['article_id'];
    $arr[$idx]['title'] = $row['title'];
    $arr[$idx]['short_title'] = $GLOBALS['_CFG']['article_title_length'] > 0 ?
    sub_str($row['title'], $GLOBALS['_CFG']['article_title_length']) : $row['title'];
    $arr[$idx]['cat_name'] = $row['cat_name'];
    $arr[$idx]['add_time'] = local_date($GLOBALS['_CFG']['date_format'], $row['add_time']);
    $arr[$idx]['url'] = $row['open_type'] != 1 ?
    build_uri('article', array('aid' => $row['article_id']), $row['title']) : trim($row['file_url']);
    $arr[$idx]['cat_url'] = build_uri('article_cat', array('acid' => $row['cat_id']), $row['cat_name']);
    }
    
    return $arr;
    }
    

     同样也是放到程序根目录下的文件 includes/init.php 下面。

    最后,就是在你想要显视最新文章的页面模板里添加如以下代码,根据模板的不同,代码有所变化。

    <ul>
    <!--{foreach from=$new_articles item=article}-->
      <li>
      <a href="{$article.url}" title="{$article.title|escape:html}">{$article.short_title|truncate:15:"...":true}</a>
    </li>
    <!--{/foreach}-->
    </ul>
    
  • 相关阅读:
    mssqlserver字符串日期互相转换
    使用TripleDES算法加密/解密
    记录google,yahoo,bing爬虫记录的插件
    C#中编写sqlserver中自定义函数,实现复杂报表
    最基本的Socket编程 C#版
    基于.net平台的web框架搭建
    未来五年程序员需要掌握的10项技能
    一段输入框控制代码,包含所有控制条件!
    C#多线程编程实例编程
    C# WinForm开发系列 Socket/WCF/Rometing/Web Services
  • 原文地址:https://www.cnblogs.com/wangblognet/p/2694874.html
Copyright © 2011-2022 走看看