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

自定义分类模板中遍历读取评论列表时,全都是第1篇文章的评论 #1768

Open
cuixiping opened this issue May 8, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@cuixiping
Copy link

描述这个 Bug

自定义分类模板中遍历读取评论列表时,只能获取到第1篇文章的评论

复现方式

复现的步骤:

category 的目录下创建缩略名为文件名的 php 文件,然后遍历文章和评论,代码大致如下

    <?php while ($this->next()): ?>
        <?php $this->content(); ?>
        <?php $this->comments()->listComments(); ?>
    <?php endwhile; ?>

结果发现,文章的遍历是对的,但是每个文章下的评论都是第1篇文章的评论。

文章A内容 --- 文章C的评论
文章B内容 --- 文章C的评论
文章C内容 --- 文章C的评论

期望的结果

遍历文章时,获取当前文章的评论列表。

可能是我的调用方法不对,但我没有找到相似的示例。

平台

  • Typecho 版本:1.2.1
  • 数据库: MySQL
@cuixiping cuixiping added the bug Something isn't working label May 8, 2024
@joyqi
Copy link
Member

joyqi commented May 9, 2024

在 index.php 中会出现这种情况么?

@cuixiping
Copy link
Author

cuixiping commented May 9, 2024

在 index.php 中会出现这种情况么?

index 没有试,不过我把comments()方法复制了一个comments2(),把其中的 \Widget\Comments\Archive::alloc($parameter); 改为 \Widget\Comments\Archive::alloc($parameter, null, false); 调用comments2从而解决该问题。

另外,大佬你的joyqi.com的SSL到期了

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