如何让首页只显示某一分类下的文章?

模板开发以及发布测试

版主: seita

回复
keinn
帖子: 63
注册时间: 2010年 3月 28日 03:11
联系:

如何让首页只显示某一分类下的文章?

帖子 keinn »

如题;
本来以为萨图腾的CMS模板里会有,可看了下,发现它是循环每一个分类来调用。

代码: 全选

   <?php while($category->next()): ?>
    <div class="index_area">
   <h3><a href="<?php $category->permalink(); ?>"><?php $category->name(); ?></a></h3>
    <ul>
     <?php
  $this->widget("Widget_Archive@$category->mid",'type=category', "mid= $category->mid" )->parse('<li><a href="{permalink}">{title}</a></li>'); ?>
    </ul>
   </div>
    <?php endwhile; ?>


请高手支招。
typecho官方文档太少。
大家东一句西一句,常用的东西也就出来了
------------
找到了:如下,但只能显出标题

代码: 全选

<?php $this->widget("Widget_Archive@$category->mid" ,array('pageSize' => '3' ,'type' => 'category'), "mid= 2")->parse('<li><a href="{permalink}">{title}</a></li>'); ?>

请问如何把文章内容也显出来?或者摘要
---------------------
这样可以显出文章内容:

代码: 全选

 <?php while($this->next()): ?>
              <div class="ak-node-post-content"><?php $this->widget("Widget_Archive@$category->mid" ,array('pageSize' => '3' ,'type' => 'category'), "mid= 1")->parse('<li><a href="{permalink}">{title}</a></li>'); ?></div>
             
              <div class="ak-node-post-content"><?php $this->content(); ?></div>
                 <?php endwhile; ?>


但是无法让标题与内容一一对应,总是会把指定分类下文章标题循环完了再出文章内容
纠结,怎么让标题与内容一一对应
keinn
帖子: 63
注册时间: 2010年 3月 28日 03:11
联系:

Re: 如何让首页只显示某一分类下的文章?

帖子 keinn »

自己搞定了,看了下数据表,调用的地方要写表里面的字段名。内容自段为text
<?php
$this->widget("Widget_Archive@$category->mid",'type=category', "mid=1" )->parse('<h1><a href="{permalink}">{title}</a></h1><p>{text}</p>'); ?>


上面的很完美。
自已美一个。
但,more标签阶段貌似不起作用。
怎么样才让只显示一部分腻??
这样做还有个文题。分不了页。
Leo
帖子: 28
注册时间: 2010年 4月 8日 13:43
联系:

Re: 如何让首页只显示某一分类下的文章?

帖子 Leo »

看来都是自己搞定了。
keinn
帖子: 63
注册时间: 2010年 3月 28日 03:11
联系:

Re: 如何让首页只显示某一分类下的文章?

帖子 keinn »

没解决继续等高人
korui
帖子: 29
注册时间: 2009年 7月 27日 05:42
联系:

Re: 如何让首页只显示某一分类下的文章?

帖子 korui »

代码: 全选

<?php
$this->widget("Widget_Archive@$category->mid",'type=category', "mid=1" )->to($myposts);
while($myposts->next()):
......
?>
keinn
帖子: 63
注册时间: 2010年 3月 28日 03:11
联系:

Re: 如何让首页只显示某一分类下的文章?

帖子 keinn »

<?php
$this->widget("Widget_Archive@$category->mid",'type=category', "mid=1" )->to($myposts);
while($myposts->next()):
......
?>


比果同时要在首页调用两次这个 出来的都是一样的内容!!!!"mid=2" 也设了的`~~~~~~~~~~
widget不能重复调用 吗?
头像
m4go
帖子: 857
注册时间: 2010年 3月 29日 02:33
来自: https://www.vpshu.com
联系:

Re: 如何让首页只显示某一分类下的文章?

帖子 m4go »

可以重复调用。只要@后面标签,以及to$不一样就行。
zou.co
帖子: 5
注册时间: 2010年 7月 25日 05:01
联系:

Re: 如何让首页只显示某一分类下的文章?

帖子 zou.co »

测试成功,标记一下
回复