typecho
typecho copied to clipboard
The slug is not automatically generated when publishing a post.
i am in the process of exploring blog platforms to migrate from WordPress. I tried installing Typecho on localhost, but I encountered an issue. Typecho does not automatically generate slugs, which is one of the most basic features of a blogging platform. Or have I missed something?
Chinese (Simplified):
我正在研究博客平台,准备从 WordPress 迁移。我尝试在本地安装 Typecho,但遇到了一个问题。Typecho 没有自动生成 slug,而这是博客平台最基本的功能之一。还是我遗漏了什么?
I fixed it by rewriting the code, in \var\Widget\Base\Contents.php
if ($insertId > 0) {
$this->applySlug(!isset($rows['slug']) || strlen($rows['slug']) === 0 ? null : $rows['slug'], $insertId);
}
change to
if ($insertId > 0) {
$this->applySlug(!isset($rows['slug']) || strlen($rows['slug']) === 0 ? $rows['title'] : $rows['slug'], $insertId);
}
if ($updateRows > 0 && isset($rows['slug'])) {
$this->applySlug(!isset($rows['slug']) || strlen($rows['slug']) === 0
? null : $rows['slug'], $updateCondition);
}
change to
if ($updateRows > 0 && isset($rows['slug'])) {
$this->applySlug(!isset($rows['slug']) || strlen($rows['slug']) === 0
? $rows['title'] : $rows['slug'], $updateCondition);
}
#1684 优化过,你可能使用的不是开发版,所以还有问题。