Noob question about Site Set Attributes (5.8)
PermalinkI'm wanting to set a global attribute for a site (a url for an external booking link). I'd like the client to be able to edit this value if they see fit and it propagate throughout the theme so I thought I'd at a new Set with a custom attribute within the Site category (presuming thats the category for sitewide attributes?). Trying it this way rather than hardcoding it into the theme pages.
Question is how do I retrieve the values inside the Site Set within my theme? My custom attribute has a handle of 'booking_url' inside a set 'booking_details'.
<?php $a = new GlobalArea('Booking Link'); $a->display($c); ?>
And just drop a content (or HTML) block in there with the link.
Custom attributes can now be globally applied to your site, and easily accessed by calling
\Site::getSite()->getAttribute(‘attribute_handle’);
I created my custom attribute in System & Settings > Basics, targeted the handle with the above code and all is well :)
I'm using that in a page template:
<?php echo Site::getSite()->getAttribute('attribute_handle'); ?>
Works in C5 version 8.5.2
Getting all attributes in a set:
http://www.webli.us/cheatsheet/doku.php#get_all_attributes_in_a_set...
Getting a specific attribute:
http://www.webli.us/cheatsheet/doku.php#get_an_attribute_key_by_han...