Site Name and Version 8

Permalink
With version 8 this does not seem to work anymore:

<?php
echo Config::get('concrete.site');
?>


Does anyone know of the current way to echo the site name?

tallacman
 
mnakalay replied on at Permalink Reply
mnakalay
I upgraded my site to v8 and this is still working
PineCreativeLabs replied on at Permalink Reply
PineCreativeLabs
I can confirm this. Tried it with different themes, got the same result. I have reported this as a bug:

https://www.concrete5.org/developers/bugs/8-0-0/site-name-does-not-r...
mnakalay replied on at Permalink Reply
mnakalay
that is really weird because even in the controller for the register single page, it is being used in the email sent
$mh->addParameter('site', tc('SiteName', $config->get('concrete.site')));
ramonleenders replied on at Permalink Reply
ramonleenders
This isn't a bug, the code just changed. Take a look in the header_required file how they pull the site config:

https://github.com/concrete5/concrete5/blob/develop/concrete/element...

It's not Config::get anymore. Try this:

$site = Core::make('site')->getSite();
$config = $site->getConfigRepository();
echo $config->get('site');


If that didn't work, I will paste the correct code tomorrow. I'm not on my desktop, so quite limited.
tallacman replied on at Permalink Reply
tallacman
thanks but that doesnt work at least in my attempt.
mnakalay replied on at Permalink Reply
mnakalay
try
\Core::make('site')->getSite()->getSiteName();


I think ramonleenders' code would work like this
$site = Core::make('site')->getSite();
$config = $site->getConfigRepository();
echo $config->get('name');
PineCreativeLabs replied on at Permalink Reply
PineCreativeLabs
This does work for me:

$site = Core::make('site')->getSite();
$config = $site->getConfigRepository();
echo $config->get('name');


The old code is going to be a big problem, because many of the themes use this, which will break a lot of sites that are using it, if they upgrade to 8 and newer.
c5hub replied on at Permalink Reply
c5hub
This may or may not be the preferred method but should work...
<?php
echo Config::get('site.sites.default.name');
?>
Steevb replied on at Permalink Best Answer Reply
Steevb
Code above worked for me this afternoon, thanks.

Quick workaround to cover 5.7 and 5.8. Needs a bit of work to target versions (Shows two links in source code).

<a href="<?php echo DIR_REL?>/"><?php echo Config::get('concrete.site');?></a>
          <a href="<?php echo DIR_REL?>/"><?php echo Config::get('site.sites.default.name');?></a>
tallacman replied on at Permalink Reply
tallacman
Thanks to all. Looks like we have a winner. Until v8.0.1 at least.
tallacman replied on at Permalink Reply
tallacman
It fails on the first call in 8.0 but the second picks it up. Time to update themes.
Steevb replied on at Permalink Reply
Steevb
like I mentioned, it shows two home links in source code. Visitors/users don't see them but search engines will. Great for SEO?
tallacman replied on at Permalink Reply
tallacman
8.0.1 fixes this