Manage contact data with Low Variables
This is the first in a series of posts where I give you some examples on how to use Low Variables to your advantage. In this example, I’ll explain how Low Variables can be used to manage contact data in ExpressionEngine.
Say you want the company name, address and other contact data displayed on the site. Basically, this is vCard information, which you might want to re-use. On my sandbox site, I’m using the company name in the footer, the full address on the contact page, marked up using the hCard microformat, and the email address is also used as the contact form recipient.
In order to re-use the data properly, we’ll create four variables: {low_contact_fn}, {low_contact_street-address}, {low_contact_locality} and {low_contact_email}. I’m using the prefix low, so regular users can edit them. The middle part of the variable name, contact groups them in the same group (you might also want to check out my Introduction to Low Variables screencast on YouTube). I’ve changed the type of each variable to Text Input. For {low_contact_email}, I enabled Early Parsing (so I can use it as input for other tags) and I’ve added a regular expression to the Pattern field, so only valid email addresses can be saved.
That only leaves the template bit. Here’s how that might look:
<div id="footer">© {current_time format="%Y"} - {low_contact_fn}</div>
<div class="vcard">
<span class="fn">{low_contact_fn}</span><br />
<span class="street-address">{low_contact_street-address}</span><br />
<span class="locality">{low_contact_locality}</span><br />
<a class="email" href="mailto:{low_contact_email}">{low_contact_email}</a>
</div>
{exp:email:contact_form recipients="{low_contact_email}"}
<!-- the contact form -->
{/exp:email:contact_form}
That’s it! You can now use Low Variables to manage contact data without the heartache!