Back to index

3. Element tags

3.1 Element tags overview

Element tags represent individual data items. All element tags have a $ sign to act as a reminder that they act in the same way as software variables. A complete element tag looks like:

<$TourCMStour t_id="3" output="t_name"$>

This will output the name of the Tour which has the ID 3. The d_id and output are known as attributes, they define exactly what content should be returned to the screen.

Context & container tags

As we have seen, the primary element tags (TourCMSoption, TourCMStour, TourCMSdeparture, TourCMSfreesale, TourCMScollection) all require the internal ID to be known in order to display data (such as d_id and t_id). This can be useful if we want to specifically list some content on a page but generally we don't want to go to the hassle of looking up all the IDs for the content that we want to display.

Instead, page context and container tags are used.

In the introduction to tags article we looked at how container tags can combine with element tags, as below:

<TourCMSlist_departures orderby="offer_datetime" order="desc" has_offer="show" maxdisplay="3">

<$TourCMStour output="t_name"$>
<$TourCMSdeparture output="d_offer_price"$>

</TourCMSlist_departures>

The key point to note from the example above is that neither the TourCMStour nor the TourCMSdeparture element tags have an ID. This is because the ID is automatically allocated to element tags that are contained within the TourCMSlist_departures container tag. In fact the TourCMSlist_departures tag allocates a d_id ID to all element tags within it (that can make use of it).

Page context

The second type of context is page context. This occurs with the two tour templates (tour & tour dates & prices) and the collection page template. On these pages we no longer need to set context using a container tag - but context is automatically set for the specific tour or collection. Again therefore we do not need to go looking up all the ID information to pull content to these pages.

Displaying information from a different Website

Multiple Websites are used in TourCMS for a variety of different purposes such as alternative languages, currencies or for providing different products under different brands. In the case of the first two examples it can sometimes be handy to display information from multiple Websites on one page. This can be achieved by using the website_id attribute.

Say for example you have a single site, powered by your primary Website in TourCMS that sells in Euros. You could have a second Website configured to sell in USD, perhaps you only use the Website for it's booking engine and don't use it to build an actual site with pages.

To output a "from price" for a Tour you would do something like:

From <$TourCMStour output="t_from_price_display"$>

Which would give you:

From €100

You could add the price from your second website in brackets using the website_id attribute like so:

From <$TourCMStour output="t_from_price_display"$>
(<$TourCMStour output="t_from_price_display" website_id="2"$>)

Which would give you:

From €100 (US $127)

XML safe & handling single and double quotes

To make content from an element tag safe to use within an XML file (such as an RSS feed) add xml="1" as an additional attribute. This will ensure that quotes and other harmful characters will be replaced with their corresponding entities.

Behind the scenes this is the code that is run in TourCMS to generate the XML safe output:

$workingon = mb_ereg_replace( "&", "&amp;", $workingon );
$workingon = mb_ereg_replace( "'", "&apos;", $workingon );
$workingon = mb_ereg_replace( '"', "&quot;", $workingon );
$workingon = mb_ereg_replace( "<", "&lt;", $workingon );
$workingon = mb_ereg_replace( ">", "&gt;", $workingon );

Content can be generated with PHP addslashes by adding addslashes="1" as an attribute. This runs the PHP addslashes function.

HTML entities

By default content that is edited within textareas (in TourCMS) will, when generated by TourCMS, be sent to you website using HTMLENTITIES. However, if you are looking to, for example, embed some flash (or other HTML markup) within your content, this will not come out right. (The code itself will be shown on the screen - rather than the output of the code). In these situations turn off HTML Entities by using html_ent="0" as an additional attribute.

Secure images and documents via SSL (https)

To make content from an element tag swap image sources (src) and document links to https (rather than http) add https_content="1" as an additional attribute. This works for normal, tour, option & collection content. Generally on your own website you will want image source calls to be insecure (http) (which is the default if the attribute not supplied) and to be secure during the online booking process.

Programming logic

Some element tags return with data such as 1 or 0. These are not intended for direct display to the screen but for use in custom, server side, development. In PHP, variables can be set as follows:

$title = '<$TourCMStour addslashes="1" t_id="20" output="t_name"$>';

Alternative programming languages, such as ASP.NET, JSP etc can be used on your own webhosting

Next: 3.2 Element tags, full list