Home  >  Article  >  CMS Tutorial  >  Why can’t I set up the Imperial CMS homepage to call data from other websites?

Why can’t I set up the Imperial CMS homepage to call data from other websites?

下次还敢
下次还敢Original
2024-04-17 00:22:011093browse

Calling other website data on the Imperial CMS homepage requires four steps: Determine the data source (website URL) Create an external data source (data source name, address, encoding, cache time) Create a data model (model fields, Calling address, calling method) Calling data (use [getfield] tag, specify field ID, model name, data ID, ispage)

Why can’t I set up the Imperial CMS homepage to call data from other websites?

##How to Empire CMS homepage calls other website data

Step 1: Determine the data source

Determine the URL of the website where the data that needs to be called is located.

Step 2: Create an external data source

In the "External Data Source" menu of the Imperial CMS backend, create a new external data source.

  • Data source name: Give the external data source a name that is easy to identify.
  • Data source address: Enter the URL of the website where the data needs to be called.
  • Data source encoding: Select the encoding method of the website, usually UTF-8 or GBK.
  • Cache time: Set the time for data caching to speed up subsequent calls.

Step 3: Create a data model

In the "Data Model" menu of the Imperial CMS background, create a new data model to store the called data .

  • Model fields: Set the fields in the data model to correspond to the data in the external data source.
  • Calling address: Enter the address of the external data source.
  • Calling method: Select the calling method, usually HTTP GET.

Step 4: Call data

Where data needs to be displayed, use the [getfield] tag of Empire CMS to call external data.

<code class="php">[getfield id=字段id model=模型名 dataid=数据id ispage=1]</code>
  • Field id: The field ID that needs to display data.
  • Model name: The name of the data model for calling data.
  • Data id: The ID of the data that needs to be displayed.
  • ispage: Whether to call in paging, 1 means yes, 0 means no.

Example:

<code class="php">[getfield id=title model=external_data dataid=1 ispage=0]</code>
This tag will call the value of the "title" field with ID 1 in the data model named "external_data".

The above is the detailed content of Why can’t I set up the Imperial CMS homepage to call data from other websites?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn