Emergency situation

In case of emergencies or breakdowns, you can send an SMS to our emergency hotline

On-call phone (SMS only)

+45 29 70 15 95

Send an SMS with the following information:

  • Your name and webshop
  • Description of the problem
  • Your callback phone number

Notes: This service is only for critical situations where your webshop is down or has serious problems. For regular support, please use our normal support channels.

Fetch content from external URL in themes

Guide to fetching content from external URLs in Shoporama themes with the Smarty fetch feature.

Reading time: approx. {eight} minutes
Developer

In Shoporama themes, you can fetch content from external URLs directly into your templates. This is useful if, for example, you want to display data from an external API, load a JSON feed, or include content from another server.

Kodeeditoren i Shoporama-admin med filliste for MBN-Delaware-temaet og Smarty-koden fra mailtemplaten after_purchase.html åben til redigering.
You’ll find the code editor under “Theme” in the theme menu. On the left, you’ll see the theme’s file list, and on the right, you can edit the Smarty code itself.

Note

The ` fetch_file ` function is available in Smarty 2 themes. In Smarty 4, use Smarty’s built-in `fetch` function instead.

Syntax and Parameters

The ` fetch_file ` function takes three parameters:

Parameter Required Description
urlYesThe URL to be retrieved (http/https only)
formatNoSet to " json " to parse as an array. Omit for plain text
assignNoVariable name to which the content is assigned

Example: Retrieve JSON data

Here, we fetch a JSON file and use the data in the template:

<{fetch_file url="https://example.com/data.json" format="json" assign="data"}>

If the JSON file contains:

{
  "name": "Billy Bob",
  "email": "billy@example.com"
}

You can now use the data like this:

<p>Name: <{$data.name}></p>
<p>Email: <{$data.email}></p>

Example: Retrieve as plain text

If you omit the format parameter, the content is returned as plain text:

<{fetch_file url="https://example.com/snippet.html" assign="snippet"}>
<div><{$snippet}></div>

Smarty 4: Use `fetch` instead

In Smarty 4 themes, use Smarty’s built-in ` fetch` function:

<{fetch file="https://example.com/data.txt" assign="content"}>
<p><{$content}></p>

Tip

Please note that external calls can affect your page’s load time. Consider caching the result or using asynchronous calls via JavaScript if the data isn’t critical to the initial page view.

Need help? Contact us at support@shoporama.dk.