I've created a custom template for Joomla 3, but want to be able to dynamically output (or otherwise work with) the 'Site Name' - as defined in the Joomla administrative interface: SYSTEM > GLOBAL CONFIGURATION > SITE > SITE NAME
.
I've accomplished something similar using JFactory / JInput in order to get the ItemID of the current page, but can't seem to determine the corresponding syntax for the Site Name.
This is the code used in order to pull ItemID, for what little it's worth;
$jinput = JFactory::getApplication()->input;
$Itemid = $jinput->get('Itemid');
Thanks in advance for any help anyone can provide.
Towards the right side of the page, under the SEO Settings header you will see the Include Site Name in Page Titles setting. You can set it to any of the following settings: You can see in our screenshot at the top of the page, our Site Name is currently set to Joomla 3 Testing.
Getting the current URL To get the URL of the current webpage do: use JoomlaCMSUriUri; $uri = Uri::getInstance(); $url = $uri->toString(); The advantage of using this method is that it handles any peculiarities of the webserver (eg Apache or IIS) and also performs some cleaning of the URL to avoid some types of injection attacks.
Uri::root ($pathonly) is a static function which returns the URL to the root of the Joomla site. It may or may not be the same as the HTTP domain, depending upon how your webserver is configured. In the common case where a Joomla instance "mysite" is installed in a directory under the webserver document root you are likely to get:
The advantage of this approach is that no changes need to be made if you change the name of your joomla site or domain, such as moving from a development environment, via testing to live, and particularly if you want to display absolute URLs on your live site.
You can get all global config using,
$config = JFactory::getConfig();
echo 'Site name is ' . $config->get( 'sitename' );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With