【求助】请大佬帮忙看一下DigestShow这个插件的问题

插件开发及发布

版主: woniou

回复
ceshi
帖子: 1
注册时间: 2018年 12月 11日 22:59

【求助】请大佬帮忙看一下DigestShow这个插件的问题

帖子 ceshi »

我用的默认typecho主题。这个插件可以设置首页、分类页、标签页等页面文章的高度,但是归档页却不生效,还是全文显示,想改一下让它也支持该怎么改呢?插件源码:

代码: 全选

<?php
/**
 * 列表页只显示摘要
 *
 * @package DigestShow
 * @author WiFeng
 * @version 1.1.0
 * @link http://521-wf.com
 */
class DigestShow_Plugin implements Typecho_Plugin_Interface
{
    /**
     * 激活插件方法,如果激活失败,直接抛出异常
     *
     * @access public
     * @return void
     * @throws Typecho_Plugin_Exception
     */
    public static function activate()
    {
        Typecho_Plugin::factory('Widget_Abstract_Contents')->contentEx = array(__CLASS__, 'render');
    }
   
    /**
     * 禁用插件方法,如果禁用失败,直接抛出异常
     *
     * @static
     * @access public
     * @return void
     * @throws Typecho_Plugin_Exception
     */
    public static function deactivate(){}
   
    /**
     * 获取插件配置面板
     *
     * @access public
     * @param Typecho_Widget_Helper_Form $form 配置面板
     * @return void
     */
    public static function config(Typecho_Widget_Helper_Form $form){
      $height = new Typecho_Widget_Helper_Form_Element_Text('height', NULL, '400', _t('摘要显示最大高度'));
        $form->addInput($height);
   }
   
    /**
     * 个人用户的配置面板
     *
     * @access public
     * @param Typecho_Widget_Helper_Form $form
     * @return void
     */
    public static function personalConfig(Typecho_Widget_Helper_Form $form){}
   
    /**
     * 插件实现方法
     *
     * @access public
     * @return void
     */
    public static function render($content, $thisObj){
      $typelist = array(
         'index',
         'index_page',
         'category',
         'category_page',
         'tag',
         'tag_page',
         'search',
         'search_page'
         
      );

      if(in_array($thisObj->parameter->type, $typelist)) {
         $pluginname = substr(__CLASS__, 0, strrpos(__CLASS__, '_'));
         $height = Typecho_Widget::widget('Widget_Options')->plugin($pluginname)->height;
         $height = intval($height);
         return '<div style="max-height:'.$height.'px;overflow:hidden;">'.$content.'</div>';
      }
      return $content;
   }
}
回复