





















从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 // 足够大的数,确保包含所有文章
]);此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。