Book a call

Fill out the form and we will call you back as soon as possible

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

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

Note that

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 retrieve (http/https only)
formatNo Set to json to parse as array.Set to json to parse as array. Omit for plain text
assignNo Set to json to parse as array.Variable name to which the content is assigned

Example: Get 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: Fetch as plain text

If you omit the format parameter, the content will be 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, you use Smarty's built-in fetch function:

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

Tip to keep in mind

Be aware that external calls can affect your page load time. Consider caching the result or using asynchronous calls via JavaScript if the data is not critical for the initial page view.

Do you need help? Contact us at support@shoporama.dk.