置顶插件Sticky 怎么让置顶的只显示标题?求解?
版主: woniou
置顶插件Sticky 怎么让置顶的只显示标题?求解?
这个置顶插件Sticky,如何让制订的文章,只显示标题,不显示内容,因为置顶太多了,首页下拉太长,求解?怎么让置顶的只显示标题?
- m4go
- 帖子: 857
- 注册时间: 2010年 3月 29日 02:33
- 来自: https://www.vpshu.com
- 联系:
Re: 置顶插件Sticky 怎么让置顶的只显示标题?求解?
首先,sticky木有这个功能,我也没翻到有这个方面的功能。
下面来说说我的解决办法。
你要置顶的日志,加一个自定义字段为top,然后,在index.php里加个判断,如果当前文章含top自定义字段,就只输出标题。
否则,正常输出。
这样,搭配插件,文章就可以首页置顶显示,但分类或标签页,正常显示了。
下面来说说我的解决办法。
你要置顶的日志,加一个自定义字段为top,然后,在index.php里加个判断,如果当前文章含top自定义字段,就只输出标题。
否则,正常输出。
这样,搭配插件,文章就可以首页置顶显示,但分类或标签页,正常显示了。
Re: 置顶插件Sticky 怎么让置顶的只显示标题?求解?
自定义字段是这样吗?我不懂PHP编程,只能看懂个大概,求大神,完整代码,万分感谢
- 附件
-
- QQ图片20160112162453.png (5.23 KiB) 查看 17693 次
- m4go
- 帖子: 857
- 注册时间: 2010年 3月 29日 02:33
- 来自: https://www.vpshu.com
- 联系:
Re: 置顶插件Sticky 怎么让置顶的只显示标题?求解?
对,就是这个。然后,你在首页输出的时候判断一下:
<?php if (isset($this->fields->top)): ?>
如果含top只输出标题
<?php else: ?>
正常输出
<?php endif; ?>
如果不会改,就把你模板的index.php发出来。
<?php if (isset($this->fields->top)): ?>
如果含top只输出标题
<?php else: ?>
正常输出
<?php endif; ?>
如果不会改,就把你模板的index.php发出来。
Re: 置顶插件Sticky 怎么让置顶的只显示标题?求解?
<?php
/**
* 这是 Typecho 0.9 系统的一套默认皮肤
*
* @package Typecho Replica Theme
* @author Typecho Team
* @version 1.2
* @link http://typecho.org
*/
if (!defined('__TYPECHO_ROOT_DIR__')) exit;
$this->need('header.php');
?>
<div class="col-mb-12 col-8" id="main" role="main">
<?php while($this->next()): ?>
<article class="post" itemscope itemtype="http://schema.org/BlogPosting">
<h2 class="post-title" itemprop="name headline"><a itemtype="url" href="<?php $this->permalink() ?>" title="<?php $this->title() ?>" target="_blank"><?php $this->sticky(); $this->title() ?><?php isNewPost($this);?></a></h2>
<ul class="post-meta">
<li itemprop="author" itemscope itemtype="http://schema.org/Person"><?php _e('作者: '); ?><a itemprop="name" href="<?php $this->author->permalink(); ?>" rel="author"><?php $this->author(); ?></a></li>
<li><?php _e('时间: '); ?><time datetime="<?php $this->date('c'); ?>" itemprop="datePublished"><?php $this->date('F j, Y'); ?></time></li>
<li><?php _e('分类: '); ?><?php $this->category(','); ?></li>
<li><?php Views_Plugin::theViews('', ' 次围观'); ?> </li>
<li itemprop="interactionCount"><a itemprop="discussionUrl" href="<?php $this->permalink() ?>#comments"><?php $this->commentsNum('评论', '1 条评论', '%d 条评论'); ?></a></li>
</ul>
<div class="content">
<a itemtype="url" href="<?php $this->permalink() ?>" target="_blank"><img src="<?php @thumbnail($this); ?>" alt="<?php $this->title() ?>"></a>
<?php $this->excerpt(200, '...'); ?> <a itemtype="url" href="<?php $this->permalink() ?>" title="<?php $this->title() ?>" target="_blank">阅读全文</a>
</div>
</article>
<?php endwhile; ?>
<?php $this->pageNav('« 前一页', '后一页 »'); ?>
</div><!-- end #main-->
<?php $this->need('sidebar.php'); ?>
<?php $this->need('footer.php'); ?>
\\\\\\\\\\\\\\\\\\\\\\\\\\\\
这是default模板里的index.php,凡是置顶的只显示标题,其他的都正常显示,万分感谢!!!!
/**
* 这是 Typecho 0.9 系统的一套默认皮肤
*
* @package Typecho Replica Theme
* @author Typecho Team
* @version 1.2
* @link http://typecho.org
*/
if (!defined('__TYPECHO_ROOT_DIR__')) exit;
$this->need('header.php');
?>
<div class="col-mb-12 col-8" id="main" role="main">
<?php while($this->next()): ?>
<article class="post" itemscope itemtype="http://schema.org/BlogPosting">
<h2 class="post-title" itemprop="name headline"><a itemtype="url" href="<?php $this->permalink() ?>" title="<?php $this->title() ?>" target="_blank"><?php $this->sticky(); $this->title() ?><?php isNewPost($this);?></a></h2>
<ul class="post-meta">
<li itemprop="author" itemscope itemtype="http://schema.org/Person"><?php _e('作者: '); ?><a itemprop="name" href="<?php $this->author->permalink(); ?>" rel="author"><?php $this->author(); ?></a></li>
<li><?php _e('时间: '); ?><time datetime="<?php $this->date('c'); ?>" itemprop="datePublished"><?php $this->date('F j, Y'); ?></time></li>
<li><?php _e('分类: '); ?><?php $this->category(','); ?></li>
<li><?php Views_Plugin::theViews('', ' 次围观'); ?> </li>
<li itemprop="interactionCount"><a itemprop="discussionUrl" href="<?php $this->permalink() ?>#comments"><?php $this->commentsNum('评论', '1 条评论', '%d 条评论'); ?></a></li>
</ul>
<div class="content">
<a itemtype="url" href="<?php $this->permalink() ?>" target="_blank"><img src="<?php @thumbnail($this); ?>" alt="<?php $this->title() ?>"></a>
<?php $this->excerpt(200, '...'); ?> <a itemtype="url" href="<?php $this->permalink() ?>" title="<?php $this->title() ?>" target="_blank">阅读全文</a>
</div>
</article>
<?php endwhile; ?>
<?php $this->pageNav('« 前一页', '后一页 »'); ?>
</div><!-- end #main-->
<?php $this->need('sidebar.php'); ?>
<?php $this->need('footer.php'); ?>
\\\\\\\\\\\\\\\\\\\\\\\\\\\\
这是default模板里的index.php,凡是置顶的只显示标题,其他的都正常显示,万分感谢!!!!
- m4go
- 帖子: 857
- 注册时间: 2010年 3月 29日 02:33
- 来自: https://www.vpshu.com
- 联系:
Re: 置顶插件Sticky 怎么让置顶的只显示标题?求解?
<div class="col-mb-12 col-8" id="main" role="main">
<?php while($this->next()): ?>
<article class="post" itemscope itemtype="http://schema.org/BlogPosting">
<h2 class="post-title" itemprop="name headline"><a itemtype="url" href="<?php $this->permalink() ?>" title="<?php $this->title() ?>" target="_blank"><?php $this->sticky(); $this->title() ?><?php isNewPost($this);?></a></h2>
<?php if (isset($this->fields->top)): ?>
<?php else: ?>
<ul class="post-meta">
<li itemprop="author" itemscope itemtype="http://schema.org/Person"><?php _e('作者: '); ?><a itemprop="name" href="<?php $this->author->permalink(); ?>" rel="author"><?php $this->author(); ?></a></li>
<li><?php _e('时间: '); ?><time datetime="<?php $this->date('c'); ?>" itemprop="datePublished"><?php $this->date('F j, Y'); ?></time></li>
<li><?php _e('分类: '); ?><?php $this->category(','); ?></li>
<li><?php Views_Plugin::theViews('', ' 次围观'); ?> </li>
<li itemprop="interactionCount"><a itemprop="discussionUrl" href="<?php $this->permalink() ?>#comments"><?php $this->commentsNum('评论', '1 条评论', '%d 条评论'); ?></a></li>
</ul>
<div class="content">
<a itemtype="url" href="<?php $this->permalink() ?>" target="_blank"><img src="<?php @thumbnail($this); ?>" alt="<?php $this->title() ?>"></a>
<?php $this->excerpt(200, '...'); ?> <a itemtype="url" href="<?php $this->permalink() ?>" title="<?php $this->title() ?>" target="_blank">阅读全文</a>
</div>
<?php endif; ?>
</article>
<?php endwhile; ?>
<?php $this->pageNav('« 前一页', '后一页 »'); ?>
</div><!-- end #main-->
请测试一下行不行
<?php while($this->next()): ?>
<article class="post" itemscope itemtype="http://schema.org/BlogPosting">
<h2 class="post-title" itemprop="name headline"><a itemtype="url" href="<?php $this->permalink() ?>" title="<?php $this->title() ?>" target="_blank"><?php $this->sticky(); $this->title() ?><?php isNewPost($this);?></a></h2>
<?php if (isset($this->fields->top)): ?>
<?php else: ?>
<ul class="post-meta">
<li itemprop="author" itemscope itemtype="http://schema.org/Person"><?php _e('作者: '); ?><a itemprop="name" href="<?php $this->author->permalink(); ?>" rel="author"><?php $this->author(); ?></a></li>
<li><?php _e('时间: '); ?><time datetime="<?php $this->date('c'); ?>" itemprop="datePublished"><?php $this->date('F j, Y'); ?></time></li>
<li><?php _e('分类: '); ?><?php $this->category(','); ?></li>
<li><?php Views_Plugin::theViews('', ' 次围观'); ?> </li>
<li itemprop="interactionCount"><a itemprop="discussionUrl" href="<?php $this->permalink() ?>#comments"><?php $this->commentsNum('评论', '1 条评论', '%d 条评论'); ?></a></li>
</ul>
<div class="content">
<a itemtype="url" href="<?php $this->permalink() ?>" target="_blank"><img src="<?php @thumbnail($this); ?>" alt="<?php $this->title() ?>"></a>
<?php $this->excerpt(200, '...'); ?> <a itemtype="url" href="<?php $this->permalink() ?>" title="<?php $this->title() ?>" target="_blank">阅读全文</a>
</div>
<?php endif; ?>
</article>
<?php endwhile; ?>
<?php $this->pageNav('« 前一页', '后一页 »'); ?>
</div><!-- end #main-->
请测试一下行不行
Re: 置顶插件Sticky 怎么让置顶的只显示标题?求解?
一切正常,非常棒!另外问下大神,我现在用的DEFAULT模板,就是每个文章很长,怎么实现电脑和手机访问都 让头部导航栏,或者LOGO 浮动置顶显示,就像官方博客的效果http://typecho.org/blog/
Re: 置顶插件Sticky 怎么让置顶的只显示标题?求解?
楼上需求涉及重写模版结构实现响应式js效果。。这个高手也得去研究下,别提手把手教要长篇细致累死人~ 建议你学习css和js然后去分析官网源码就能试着移植到自己博客,有成果还可以在这分享给其他伸手党:)
Re: 置顶插件Sticky 怎么让置顶的只显示标题?求解?
你好,我尝试在我的主题中的index.php中修改,但没有生效,可否麻烦您帮我看一下哪里错了?谢谢