简体   繁体   中英

Using Drupal to store json content and images for a site

I'm planning to use drupal to store some JSON content for our company site. So we don't have to hardcode the strings in our dynamic web project and we can change the strings in drupal and publish the content that would ultimately display in the site.

The same thing for images. We wanted to store images in drupal and the site would retrieve the images from there. And changing the images in drupal CMS would change the site's look.

The Problem: I installed drupal, and in the contents page on top I was not able to find ways of publishing json content and how can I get the URI that I can CURL to get the content?

Or is drupal only for creating sites? and not a generic content?

An example of content that I'm looking to store is here:

{
    "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"
                }
            ]
        }
    }
}

Thanks

Since you need only to Read data from Drupal you can use any "REST" related module that returns Drupal content as json. Here is a very sort list of such modules. I would stick with the first one ( views_datasource ).

Another option would be to create your own module using the Drupal core API function drupal_json_output .

I would install the services module, and create a content type in Drupal called "JSON Page" for instance.

The type will have fields corresponding the the various data you want to store in JSON, for instance "Header", "Title small", etc.

Your editors could simply create and edit content of this type on the Drupal site and the other site would make a REST call to retrieve the information from the Drupal site.

This could easily be returned as a JSON object by the services module while letting your editors use a user friendly interface with WYSIWYG etc. on the Drupal site.

https://drupal.org/project/services

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM