Bolt CMS - 自动关系

时间:2015-09-28 12:08:09

标签: symfony bolt-cms

我是Bolt CMS的新手,但到目前为止看起来还不错。我现在的目标是为文章创建评级。为此,我创建了ratings内容类型,并在其中放置了article_iduser_idrating字段。现在我如何设置这些字段以创建它们之间的关系?

由于Bolt对Symfony很反感,我希望它能使用Doctrine及其工具。

我目前ratings的内容类型很差:

ratings:
    name: Ratings
    slug: ratings
    singular_name: Rating
    singular_slug: rating
    fields:
        article_id:
            type: integer
        user_id:
            type: integer
        rating:
            type: integer

2 个答案:

答案 0 :(得分:0)

评级究竟应该做什么?访客必须能够评价文章吗?在这种情况下,您可以查看rateit扩展http://extensions.bolt.cm/view/5d137130-4ab8-4e75-9d58-43f3f99c5a5a

答案 1 :(得分:0)

如果我理解你的问题,你想要的是,评级和文章的关系。 这是代码。文章有很多评级。

ratings:
    name: Ratings
    singular_name: Rating
    fields:
        name:
            label: Name
            type: text
            group: General
        email:
            label: Email
            type: text
            group: General

articles:
    name: Articles
    singular_name: Article
    fields:
        name:
            label: Name
            type: text
            group: General
    relations:
        ratings:
            multiple: true
            label: "Choose ratings"

了解BOLT CMS是建立在Symphony和Silex肩上的,这很重要。但是为了获取内容,您不必使用Doctrine Query。如果您使用的是BOLT 3. *或Backend.php,如果您使用的是旧版本,我建议您查看具有Records.php的Backend文件夹。检查editContent操作。如果你想要使用Frontend.php,那么很容易遵循代码。

希望这有帮助!!!

相关问题