怎么获取首页最近半年热门文章?

chenmo  (UID: 3151) [复制链接]
帖子链接已复制到剪贴板
帖子已经有人评论啦,不支持删除!

2699 2

我用的是JOE主题,在widget.php里修改代码如下:

<?php
class Widget_Contents_Hot extends Widget_Abstract_Contents
{
    public function execute()
    {
        $this->parameter->setDefault(array('pageSize' => 10));
        $select = $this->select();
        $select->cleanAttribute('fields');
    //    $period = time() - 2592000; // 单位: 秒, 时间范围: 30天
     $period = strtotime("-180 days"); 
        $this->db->fetchAll(
            $select->from('table.contents')
                ->where("table.contents.password IS NULL OR table.contents.password = ''")
                ->where('table.contents.status = ?', 'publish')
                
                ->where('table.contents.created > ?','$period')
                ->where('table.contents.type = ?', 'post')
                ->limit($this->parameter->pageSize)
                ->order('table.contents.views', Typecho_Db::SORT_DESC),
            array($this, 'push')
        );
    }
}

怎么修改都没效果,有大佬指导一下吗?

这家伙太懒了,什么也没留下。
已有评论 ( 2 )
  • 头像
    chenmo (UID: 3151)
    1楼

    不是官方的啊 是JOE主题core/widget.php 文件啊

    它的首页热门文章是这个代码: 所以应该是改那个代码。

    		<?php if ((is_numeric($this->options->JIndex_Hot)) &&  ($this->options->JIndex_Hot >= 1)) : ?>
    						<?php $this->widget('Widget_Contents_Hot@Index', 'pageSize=' . $this->options->JIndex_Hot)->to($item); ?>
    						<div class="joe_index__hot">
    							<ul class="joe_index__hot-list">
    								<?php while ($item->next()) : ?>
    									<li class="item">
    										<a class="link" href="<?php $item->permalink(); ?>" title="<?php $item->title(); ?>">
    											<figure class="inner">
    												<span class="views"><?php echo number_format($item->views); ?> ℃</span>
    												<img width="100%" height="120" class="image lazyload" src="<?php _getLazyload(); ?>" data-src="<?php echo _getThumbnails($item)[0]; ?>" alt="<?php $item->title(); ?>" />
    											</figure>
    										</a>
    										<div class="item-body">
    											<h2 class="item-heading">
    												<a title="<?php $item->title(); ?>" alt="<?php $item->title(); ?>" href="<?php $item->permalink(); ?>"><?php $item->title(); ?></a>
    											</h2>
    											<div class="item-tags-category">
    												<span class="item-category">
    													<?php
    													$color_array = [
    														'c-blue',
    														'c-yellow'
    													];
    													foreach ($item->categories as $key => $value) {
    													?>
    														<a class="but <?= $color_array[$key] ?>" title="查看更多分类文章" href="<?= $value['url'] ?>">
    															<i class="fa fa-folder-open-o"></i><?= $value['name'] ?>
    														</a>
    													<?php
    													}
    													?>
    												</span>
    												<span class="item-tags">
    													<?php $item->tags('')  ?>
    												</span>
    											</div>
    										</div>
    									</li>
    								<?php endwhile; ?>
    							</ul>
    						</div>
    					<?php endif; ?>

     

    我是想这个时间判断代码是写错了吗?两个都不起效果。

    //    $period = time() - 2592000; // 单位: 秒, 时间范围: 30天
         $period = strtotime("-180 days"); 
     
  • 头像
    chenmo (UID: 3151)
    2楼
    六六丶 是在这里改的,使用typecho的数据库查询就可以了
    但是改了没效果    感觉加不加这个时间限定都不起作用。
域名市场
   域名载入中...
创建新帖
自助推广购买广告位
确认删除
确定要删除这篇帖子吗?删除后将无法恢复。
删除成功
帖子已成功删除,页面将自动刷新。
删除失败
删除帖子时发生错误,请稍后再试。