Get value of Site Custom Attribute in template file (8.x.x)

Permalink
Hi, people!
I've created a Custom Attribute for Site object (in Dashboard section System & ... -> Basics -> Names & Attributes). It could be a Logo image for my website. I see that in database table this attribute is marked as 'sitekey'. Maybe somebody knows convenient method to get attribute value in template file?

$c->getAttribute('logo');
- Doesn't work

I've found out to do it like (using object Site):
$site = Site::getSite();
$lLogoAttr = $site->getAttributeValueObject('logo');
if (!is_null($lLogoAttr)) {
    $lLogoVal = $lLogoAttr->getValue();
    $lLogoId = $lLogoVal->getFileID();
    $lLogoPath = File::getRelativePathFromID($lLogoId);
}


Can somebody suggest something else? Something like getAttributeByHandle?

 
serot0nin replied on at Permalink Reply
serot0nin
Once you have the site object:
$site->getAttribute('logo');


So, in other words:
$site = Site::getSite();
$logoAttr = $site->getAttribute('logo');