Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to output 'Site Name' in Joomla 3.x with PHP?

Tags:

php

joomla

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.

like image 483
Hobbes Avatar asked Jun 23 '14 12:06

Hobbes


People also ask

How to include site name in page titles in Joomla?

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.

How do I get the current URL in Joomla?

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.

How do I find the root of a Joomla site?

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:

Can I change the name of my Joomla site or domain?

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.


1 Answers

You can get all global config using,

$config = JFactory::getConfig();
echo 'Site name is ' . $config->get( 'sitename' );
like image 149
Rikesh Avatar answered Oct 27 '22 00:10

Rikesh