Globals
Last updated: May 30, 2024

Introduction

Globals are a great way of having information available across the entire website. Where an element attached to a section is only available within that specific section, the elements attached to a global are available through all sections, pages and even the layout file. If you change the information in a global, it will change across the entire website.

Creating a global

Creating a global is fairly straight forward.

Just head over to the Globals section in the menu and click 'Add global. Now all you have to do is find a suitable name for your global. This name will also be used as identifier in your view files.

After you have created a global, you can start adding elements to the global by clicking 'Add element'. Let's say you want your contact information to be a global. Then add 3 text elements for name, phone and email. If you have done so, click 'Save'.

To start adding information to you contact information global, click 'Edit global', and once you're finished, click save. Now this global holds your contact information.

This is a fairly simple example, but you can use globals for anything you want to be available across the entire website.

Displaying global data

Since a global can have all types of elements, there is not 1 way to implement a global into a view file.

Refer to the documentation of the specific element, in order to find out how the information from the global can be implemented in the view file.

But in order to collect the global information, you can use this approach..

<?php

$globalData = $webigniter->getGlobal('contactinfo'); //where contactinfo is the handle of your global

echo $globalData['phone']; //Display the element with handle name 'phone'
?>

The handle can be found in the globals overview in the CMS, when logged in as an admin.