【问题标题】:Symfony 3 | FOSCommentBundle manage many Threads / CommentsSymfony 3 | FOSCommentBundle 管理许多线程/评论
【发布时间】:2016-09-14 20:16:57
【问题描述】:

我在我的项目中使用 FOSCommentBundle,我已经为它配置了一个线程和一个评论类,这正在工作。 但现在我需要管理多种类型的线程和评论。

例如,我有带有 cmets 的 News,我有带有 cmets 的 Contents。 当然,新闻cmets和内容cmets是不一样的。

我不知道如何在 config.yml 中做到这一点:

fos_comment:
    db_driver: orm
    class:
        model:
            comment: Project\MyBundle\Entity\News
            thread: Project\MyBundle\Entity\Comment

如何添加我的其他线程/评论类型?或者我该如何处理这种情况?

TY

【问题讨论】:

    标签: comments symfony foscommentbundle


    【解决方案1】:

    在您要使用 FOSCommentBundle 的模板中,您必须输入以下代码:

    {% include 'FOSCommentBundle:Thread:async.html.twig' with {'id': 'foo'} %}
    

    因此,在{'id':'foo'} 部分中,您可以为任何您想要的线程设置不同的 id,甚至可以为任何新闻设置不同的线程,例如

    {% include 'FOSCommentBundle:Thread:async.html.twig' with {'id': 'news'~news.id} %}
    

    【讨论】:

    • 嗨@REDMAN,感谢您的回答。我在 GitHub 存储库上发布了我的问题:github.com/FriendsOfSymfony/FOSCommentBundle/issues/567,有人回答了我大致相同的答案。在评论类型的功能中,我只需要使用一个具有不同 id 的表。例如,我必须使用字段“ThreadId”= news-1 / news-2 / content-1 / content-2 做一个表“Comment”,这不是我想要的。我真的需要两个不同的评论表,一个带有“NewsId”,另一个带有“ContentId”。我没有找到办法,所以几周前我放弃了。 TY
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-31
    相关资源
    最近更新 更多