兼容1.3.0
This commit is contained in:
浪子 2025-06-27 17:29:49 +08:00
parent 8ab8213a12
commit 9f80798452
3 changed files with 26 additions and 17 deletions

View File

@ -3,7 +3,7 @@
<?php while ($this->next()): ?>
<?php
$coverImage = getPostCover($this->content, $this->cid);
$colors = ['bg-primary', 'bg-secondary', 'bg-success', 'bg-danger', 'bg-warning', 'bg-info', 'bg-transparent', 'bg-gradient'];
$colors = ['bg-primary', 'bg-secondary', 'bg-success', 'bg-danger', 'bg-warning', 'bg-info'];
?>
<article class="block card-plain post-item col-md-6 col-12 post-item-card">
<div class="p-block post-item-block">

View File

@ -4,7 +4,7 @@
*
* @package Typecho Pouck Theme
* @author 老孙博客
* @version 1.0.1
* @version 1.0.3
* @link http://www.imsun.org
*/
@ -22,6 +22,7 @@ $this->need('sticky.php');
<?php while ($this->next()): ?>
<?php
$coverImage = getPostCover($this->content, $this->cid);
$colors = ['bg-primary', 'bg-secondary', 'bg-success', 'bg-danger', 'bg-warning', 'bg-info'];
?>
<article class="block card-plain post-item p-block post-item-list">
<div class="thumbnail">
@ -34,7 +35,7 @@ $coverImage = getPostCover($this->content, $this->cid);
<h2 class="info-title">
<?php if (isset($this->isSticky) && $this->isSticky): ?><?php echo $this->stickyHtml; ?><?php endif; ?>
<?php foreach($this->categories as $category): ?>
<a class="badge d-none d-md-inline-block bg-primary ahfff" href="<?php echo $category['permalink']; ?>">
<a class="badge d-none d-md-inline-block <?php echo $colors[array_rand($colors)]; ?> ahfff" href="<?php echo $category['permalink']; ?>">
<i class="fa-regular fa-folder-open"></i> <?php echo $category['name']; ?>
</a>
<?php endforeach; ?>

View File

@ -110,7 +110,9 @@ if ($totalViews === null) $totalViews = 0;
'table.contents.authorId',
'table.contents.type',
'table.contents.status',
'table.contents.commentsNum'
'table.contents.commentsNum',
'table.contents.order',
'table.contents.template'
)
->from('table.contents')
->where('table.contents.type = ?', 'post')
@ -136,17 +138,23 @@ if ($totalViews === null) $totalViews = 0;
<div class="mt20">
<?php foreach ($hotPosts as $post): ?>
<?php
// 完整处理文章数据
$widget = Typecho_Widget::widget('Widget_Abstract_Contents');
// Typecho 1.3.0 兼容处理
$widget = $this->widget('Widget_Archive@post_' . $post['cid'], 'type=post');
try {
$post = $widget->filter($post);
if (empty($post['title']) || empty($post['slug'])) {
continue; // 跳过无效数据
}
$post['title'] = htmlspecialchars($post['title']);
$post['slug'] = htmlspecialchars($post['slug']);
if (empty($post['permalink'])) {
$post['permalink'] = Typecho_Common::url($post['slug'], $this->options->index);
$widget->setArchiveProperty('cid', $post['cid']);
$widget->setArchiveProperty('title', $post['title']);
$widget->setArchiveProperty('slug', $post['slug']);
$widget->setArchiveProperty('created', $post['created']);
$widget->setArchiveProperty('authorId', $post['authorId']);
$widget->setArchiveProperty('type', $post['type']);
$widget->setArchiveProperty('status', $post['status']);
$widget->setArchiveProperty('commentsNum', $post['commentsNum']);
// 生成正确链接
$permalink = $widget->archiveUrl;
if (empty($post['title']) || empty($permalink)) {
continue;
}
} catch (Exception $e) {
continue;
@ -157,7 +165,7 @@ if ($totalViews === null) $totalViews = 0;
<i class="fa fa-angle-right t-sm c-sub mr-1"></i>
<a class="a-link t-w-400 t-md"
title="<?php echo htmlspecialchars($post['title']); ?>"
href="<?php echo htmlspecialchars($post['permalink']); ?>">
href="<?php echo htmlspecialchars($permalink); ?>">
<?php echo htmlspecialchars($post['title']); ?>
</a>
</h2>
@ -202,8 +210,8 @@ if ($totalViews === null) $totalViews = 0;
<?php
$tags = \Widget\Metas\Tag\Cloud::alloc('sort=count&desc=1');
if ($tags->have()):
// 定义可用的颜色类数组
$colors = ['bg-primary', 'bg-secondary', 'bg-success', 'bg-danger', 'bg-warning', 'bg-info', 'bg-transparent', 'bg-gradient'];
// 定义可用的颜色类数组
$colors = ['bg-primary', 'bg-secondary', 'bg-success', 'bg-danger', 'bg-warning', 'bg-info'];
?>
<div class="pk-widget p-block ">
<div>