【问题标题】:Using Drupal to store json content and images for a site使用 Drupal 存储站点的 json 内容和图像
【发布时间】:2013-12-05 20:15:15
【问题描述】:

我打算使用 drupal 为我们公司的网站存储一些 JSON 内容。因此,我们不必在动态 Web 项目中对字符串进行硬编码,我们可以在 drupal 中更改字符串并发布最终将显示在站点中的内容。

图像也是如此。我们想将图像存储在 drupal 中,站点将从那里检索图像。并且更改 drupal CMS 中的图像会改变网站的外观。

问题: 我安装了drupal,在顶部的内容页面中我找不到发布json内容的方法,我如何获取可以CURL获取内容的URI?

或者drupal 只用于创建网站?而不是通用内容?

我要存储的内容示例如下:

{
    "Login_Page": {
        "Header": "Indeed, It's the most wonderful time of the year. Text comes from cms",
        "Title_Small": "Get the best deals for the holiday season.",
        "features": {
            "list": [
                {
                    "value": "Customizable, smart items.",
                    "image": "http://image/coming/from/cms.jpg"
                },
                {
                    "value": "Device Monitoring software",
                    "image": "http://image/coming/from/cms.jpg"
                },
                {
                    "value": "Internet of things is here",
                    "image": "http://image/coming/from/cms.jpg"
                }
            ]
        }
    }
}

谢谢

【问题讨论】:

  • 为什么不将它们存储在 MySQL 数据库中并使用 phpMyAdmin 进行编辑?为什么要安装完整的 CMS 来修改 JSON 数组?
  • @Pitchinnate 谢谢。这是保存可由内容管理员和营销人员编辑的内容的推荐方式。我不想在营销人员的机器上安装 phpMyAdmin 或 MysqlWorkBench 来编辑我们网站中显示的简单字符串。毕竟这是内容。 CMS 的“C”部分。而且不只是 json 数组,我在 CMS 中保存了真实的图像。

标签: php json architecture drupal-7 content-management-system


【解决方案1】:

由于您只需要从 Drupal 读取数据,因此您可以使用任何将 Drupal 内容返回为 json 的“REST”相关模块。这是此类模块的非常分类的列表。我会坚持第一个(views_datasource)。

另一种选择是使用 Drupal 核心 API 函数 drupal_json_output 创建您自己的模块。

【讨论】:

    【解决方案2】:

    我会安装服务模块,并在 Drupal 中创建一个名为“JSON 页面”的内容类型。

    该类型将具有与您要存储在 JSON 中的各种数据相对应的字段,例如“Header”、“Title small”等。

    您的编辑者可以简单地在 Drupal 站点上创建和编辑这种类型的内容,而其他站点将进行 REST 调用以从 Drupal 站点检索信息。

    服务模块可以轻松地将其作为 JSON 对象返回,同时让您的编辑人员使用 Drupal 站点上的所见即所得等用户友好界面。

    https://drupal.org/project/services

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多