t3blog - 用户写评论时如何清除缓存?
当用户写评论时,评论不会立即可见。如果我手动清除缓存,它就会变得可见。
通常 t3blog 将帖子和评论存储在 t3blog 页面本身中,然后应该能够通过这种方式清除缓存。
TCEMAIN.clearCacheCmd = all
然而,在我的 t3blog 设置中,帖子和评论位于单独的 sys 文件夹中。这是设置打字稿
plugin.tx_t3blog_pi1.blogPid = 21
有没有办法在用户提交新评论时触发清除缓存?
When a user writes a comment then it doesn't become visible right away. It becomes visible if I clear the cache manually.
Usually t3blog stores posts and comments within the t3blog page itself and then one should be able to clear the cache this way.
TCEMAIN.clearCacheCmd = all
However in my t3blog setup the posts and comments are in a separate sysfolder. Here is the setup typoscript
plugin.tx_t3blog_pi1.blogPid = 21
Is there a way I can trigger clear cache when the user submits a new comment?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我尝试安装“aftercommentinsertion”挂钩未成功。
最后我通过修改t3blog本身解决了这个问题,这样就可以通过typoscript指定需要清除的页面的uid。
我已将此代码发送给 Dmitry Dulepov(t3blog 的作者)。
I have unsuccessfully tried installing an 'aftercommentinsertion' hook.
Finally I solved it by modifying t3blog itself, so that you can specify the uid of the pages that needs to be cleared via typoscript.
I have sendt this code to Dmitry Dulepov (the author of t3blog).
您可以在保存您的博客文章的 sysfolder (uid=21) 的 PAGE TS 中添加此行:
该行将告诉新的博客文章将触发该确切页面列表的清除缓存。我认为您的用户需要清除缓存的权限...
它进入您的系统文件夹的 PAGE TS 而不是插入您的博客的一个或所有页面的原因是...它们(可能)都被缓存了。您的 sysfolder 未缓存,新记录将被 TYPO3 注意到,并欺骗您刚刚通过逗号分隔字符串定义的缓存页面的清除缓存。
You can add this line in your PAGE TS of the sysfolder (uid=21) holding your blog post:
That line will tell that new blog posts shall trigger a clear cache of that exact list of pages. I think your users will need rights to clear cache though...
Reason it goes into the PAGE TS of you sysfolder and not one or all of the pages where your blog is inserted is that... they are (probably) all cached. Your sysfolder is not cached and the new record will be noticed by TYPO3 and tricker a clear cache of the cached pages you just defined by your comma separated string.
您是否尝试将clearCacheCmd包含在存储注释的sys文件夹的页面TSconfig中?您可以使用“全部”、“页面”或相关页面 uid,参见:http://typo3.org/documentation/document-library/core-documentation/doc_core_tsconfig/4.3.2/view/1/5/#id2505694
这应该如果“用户”是具有相关权限的后端用户,则可以工作 - 但我想,当你说“用户写评论”时,它是你正在谈论的前端用户,然后这可能不会有太大影响帮助。
解决方案是让扩展程序在收到评论后清除缓存。您可能无法做到这一点,但快速解决此问题的方法是将页面标记为不可缓存(“禁用缓存”,“行为”选项卡)。但请注意,这会导致您的服务器受到影响。
Did you try to include the clearCacheCmd in the page TSconfig of the sysfolder where the comments are stored? You can use "all", "pages" or the relevant page uids, cf: http://typo3.org/documentation/document-library/core-documentation/doc_core_tsconfig/4.3.2/view/1/5/#id2505694
This should work if the "user" is a backend user with the relevant priveleges - but I guess, when you say "a user writes a comment", it is a front end user you are talking about, and then this will probably not be of much help.
The solution then would be to have the extension clear the cache upon receiving a comment. This might not be possible for you to do, but the quick fix to this is to mark the page as not cacheable ("Disable cache", Behavior tab). Beware, though, this will cause your server to suffer.