Creative uses for Low Variables

Before Low released Low Variables, managing all those odd bits of content in ExpressionEngine was a case of using not so flexible Global variables, or creating numerous extra Channels to hold a myriad of content bits and pieces, neither method as efficient as we’d like it to have been.

Fortunately Low Variables (LV) has changed the game and offers a huge number of possibilities for managing content in EE.

This is a list of a few things I’ve used LV for. Some of them require basic EE template conditionals and other template logic so I suggest you head over to https://gotolow.com/addons/low-variables and read through the docs so you can implement them your way.

1. Addresses and contact details

Set up a few Text input fields and give your client the ability to update their contact details easily and quickly. I like to set them up like this:

  • Company name [Text input]
  • Address line 1 [Text input]
  • Address line 2 [Text input]
  • Town/City [Text input]
  • Postal code [Text input]
  • Country [Text input]
  • Telephone [Text input]
  • General email address [Text input]

Sample code:

<h3>Our address</h3>
<p>
{lv_company}<br />
{lv_address1} {lv_address2}<br />
{lv_city}<br />
{lv_postalcode}
</p>
<p>Email: <a href=“mailto:{lv_email}”>{lv_email}</a></p>
<p>Phone: <a href=“tel:{lv_telephone}”>{lv_telephone}</a></p> 

2. Terms/privacy page content

“Legal” pages need to live somewhere but sacrificing a whole Channel for content that might rarely change is a bit of a waste in my book. Instead set up a few LV fields to hold the infomation:

  • Terms page heading [Text input]
  • Terms page content [Textarea or WYSIWYG]
  • Privacy page heading [Text input]
  • Privacy page content [Textarea or WYSIWYG]

Sample code:

<h1>{lv_terms_heading}</h1>
{lv_terms_content}

3. Forms

If you use hard coded forms, such as EE’s stock form or Freeform, you can still give your clients some control by adding a few LV fields:

  • Form page heading [Text input]
  • Form page intro copy [Textarea or WYSIWYG]
  • Input help text [Text input] - one LV field for each common input, allows client to modify field instructions
  • Thanks page heading [Text input]
  • Thanks page message [Textarea or WYSIWYG]
  • Recipient email address [Text input] - requires early parsing, embed this as your forms recipient parameter value

You could also use LV “address” field content to populate the address and contact details on your contact page.

4. Images

Home page slideshows and the like are commonly used but sometimes need to be standalone and not tied to one particular Channel. In cases like this you can add a bunch of LV fields to let your clients choose images and add captions/textural content. Alternatively LV now supports Matrix which makes it super easy to add as many bits of data s you need.

It’s just as easy to add other LV fields for changing general images, maybe the site logo if they want to make their logo bigger (only joking!), “default” images or whatever your clients need to be able to manage that doesn’t naturally fall under a Channel entry.

5. Switch things on/off

Using an LV Radio input you can add a simple Yes/No option which is great for turning things like certain content block on or off. On one site I used this technique to let the site owner show or hide a link to book an event. If the radio button value was “Yes” the book link was output into a template, if “No” it wasn’t output and replaced with a message such as “Sold out” - simples! The fields I set up for this were:

  • Enable booking? [Radio buttons Yes|No]
  • Booking link [Text input] - link to external booking site
  • Booking link text [Text input]
  • Booking disabled message [Text input]

Sample code (note “Early parsing” must be enabled for conditionals to work):

{if lv_booking_enabled == “Yes”}
<p><a href=”{lv_booking_link}”>{lv_booking_link_text}</a></p>
{/if}

{if lv_booking_enabled == “No”}
<p>{lv_booking_disabled_text}</p>
{/if} 

6. Changing a category

Using LV’s “Select category” variable type it’s possible to customise what categories are used when outputting a list of entries. As an example a site had a “Christmas” news category but those news items only get displayed during December. For the client it was a simple matter of selecting (or deselecting) the category from the LV field to tailor their news output.

7. Change number of items in a list

Sometimes clients need to be able to modify how many items appear in any Channel entries list. Adding a Text input (or Select field with some predefined numbers) allows clients to change the number on the fly - requires early parsing.

8. Home page content

Home pages can be odd things. Sometimes they’re pretty straightforward to build up by pulling in content from a few Channels, but other times the home page content is so diverse you need to dedicate a whole channel and custom fields to it - that’s not always practical.

On a site I built recently the home page had a lot of stuff going on and would have required a dedicated home page channel and 20 or so custom fields. That’s quite a lot of Channel resources for just one page so I created a set of LV fields so each piece of content could be managed easily, including an image slideshow.

9. Custom messages

Ever had a client that wanted to occasionally display a simple message on the site, maybe an update for visitors, or an emergency announcement? LV makes this one very easy, all you need is a couple of fields, a radio button pair to turn the message on or off (see item 5) and an input for the message:

  • Enable announcement? [Radio buttons Yes|No]
  • Announcement text [Textarea]

Sample code:

{if lv_announcement_enabled == “Yes”}
{lv_announcement_text}
{/if} 

10. General file downloads

Using LV’s “Select file” variable type you can set up some File upload/select fields to hold generic download documents, here’s a few uses I’ve found:

  • Generic booking forms (.pdf/.doc)
  • Downloadable legal documents
  • Publicity material, such as an official photo for press media
  • Upload files for use in future Channel entries

Low Variables is one of those essential ExpressionEngine addons that makes life so much easier, not just for clients, but for developers as well. If you haven’t given it a go you should do - http://gotolow.com/addons/low-variables

You might also like

You don't know unless you ask

Contact me today