主题XaInk支持Typecho1.3

从Typecho发布新版1.3后,我自己冒冒失失的自己升级到1.3,整体看了下界面和文章显示没有什么问题,以为就没问题了,可以自动兼容1.3版本。

网友反馈了一些升级到1.3的一些问题后,自己也花时间查了一下,现在 github 升级到1.7.0,支持Typecho 1.3了。

碰到了一些问题,简单反馈下:

  • v1.3后分类获取不再支持Widget_Metas_Category::getAllChildren($mid),子分类需要自行去写方法获取,可以使用以下方法:

    function GetCategoryChildren($parentMid) {
      $children = [];
      $all = Widget::widget('Widget\Metas\Category\Rows');
      
      if ($all) {
          while ($all->next()) {
              if ((int)$all->parent === (int)$parentMid) {
                  $children[] = [
                      'mid'   => (int)$all->mid,
                      'name'  => $all->name,
                      'permalink'   => $all->permalink,
                      'count' => (int)$all->count,
                      'description' => $all->description
                  ];
              }
          }
      }
      
      return $children;
    }
  • v1.3后在主题中获取的$this->PageRow不再为数组了,改为对象了,可以使用以下方法兼容:

    function GetPageRowValue($data, $key, $default = '') {
      if (is_array($data)) {
          return isset($data[$key]) ? $data[$key] : $default;
      } elseif (is_object($data)) {
          return isset($data->$key) ? $data->$key : $default;
      }
      return $default;
    }
  • v1.3使用Db查询获取文章使用$row = $widget->filter($row);不再自动注入分类信息、链接信息,需要使用Widget方法获取文章信息:

    $allPosts = \Typecho\Widget::widget('Widget\Contents\Post\Recent', [
      'pageSize' => 100000 // 足够大的数,确保包含所有文章
    ]);
版权属于: 小A 本文链接: https://www.xiaoa.me/archives/xaink_typecho1_3.html 转载申明: 转载请保留本文转载地址,著作权归作者所有。

评论 1

  1. 蜡客小生

    😊😊辛苦辛苦。。我空闲了,再升级。

    昨天 - 中国广西桂林市移动
没有更多啦