Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The slug is not automatically generated when publishing a post. #1849

Open
macosupdate opened this issue Jan 21, 2025 · 2 comments
Open

The slug is not automatically generated when publishing a post. #1849

macosupdate opened this issue Jan 21, 2025 · 2 comments
Labels
bug Something isn't working

Comments

@macosupdate
Copy link

macosupdate commented Jan 21, 2025

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,而这是博客平台最基本的功能之一。还是我遗漏了什么?

Image

Image

@macosupdate macosupdate added the bug Something isn't working label Jan 21, 2025
@macosupdate
Copy link
Author

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);
        }

@sy-records
Copy link
Member

#1684 优化过,你可能使用的不是开发版,所以还有问题。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants