Best ways to grab settings & page data in 5.8

Permalink
Hi There,

Building our first 5.7/5.8 site and it's been 4 years since we built a site from scratch (in 5.6) - so there's a bit of head scratching.

Here's an example of data we we'd grab in 5.6 for Facebook OG, micro formats etc...

// Page data - body classes, SEO, microformats, social sharing
    $pageTypeClass = $c->getCollectionTypeHandle();
    $pageNameClass = str_replace(' ', '', strtolower($c->getCollectionName()));
    $heroClass = $c->getCollectionAttributeValue('hero_color');
    $siteName = SITE;
    $pagePath = $c->getCollectionPath();
    $url=Loader::helper('navigation');
    $pageUrl=$url->getCollectionURL($c);
    $pageUrl=preg_replace("/index.php\?cID=1$/","",$pageUrl); // Get page conical url (includes domain, removes index.php)
    $pagePath = $c->getCollectionPath(); // Get page slug/path
    // Page title
    if($c->getCollectionAttributeValue('meta_title')) {
        $pageTitle = $c->getCollectionAttributeValue('meta_title');
    } else {
        $pageTitle = $c->getCollectionName();

Questions

1. How do you grab the site name in 5.8?
Previously we used the SITE constant but that doesn't seem to exist in 5.8 right?

2. Are there cleaner/better ways to grab this kind of data in 5.8?
It's been while since we've built a site from scratch so keen to see how others do this, especially in the new c5 version.

3. Easy Docs
We're designers so find API docs confusing (and assume knowledge), is there a place that explains how to grab data out of different areas of C5.8?

Any help or pointers in the right direction would be most welcome.

Cheers

 
MrKDilkington replied on at Permalink Reply
MrKDilkington
Hi cmscss,

In concrete5 v8, you can add attributes to the site itself, just like you would a page.

Example: get the site name
$siteName = Site::getSite()->getSiteName();
echo $siteName;

Example: get a site attribute
Site::getSite()->getAttribute('attribute_handle');

You can create and set site attributes on the Name & Attributes page:
Dashboard > System & Settings > Basics > Name & Attributes > Custom Attributes