Joomla! Programmierung/Framework/JFactory/getConfig

Aus Joomla! Dokumentation

Wechseln zu: Navigation, Suche

JFactory/getConfig Liefert eine Referenz zu dem globalen JRegistry Objekt. Wird nur neu erstellt, wenn es noch nicht existiert.

Inhaltsverzeichnis

Syntax

static getConfig( [$file], [$type] )
Parameter Datentyp Beschreibung Standardwert
$file string Pfad zur Konfigurationsdatei. Wenn null und die Instanz noch nicht existiert wird Datei:file_white.png libraries/joomla/config.php angenommen. null
$type string Typ der Konfigurationsdatei. 'PHP'

Beispiele

Wert aus globaler Konfiguration laden

Es ist Prinzipiell eleganter mittels getApplication und getCfg werte aus der Globalen Konfiguration zu laden, aber trotzdem hier mal ein Beispiel, wie man mittels getConfig an die Werte kommt.

$config = JFactory::getConfig();
echo 'Der Seitenname lautet ' . $config->getValue( 'config.sitename' );

Siehe auch

Quellcode

JFactory -> getConfig in Joomla! 1.5.14

Datei:folder_blue.png libraries/joomla

  • Datei:file_php.png factory.php
  1. function &getConfig($file = null, $type = 'PHP')
  2. {
  3. static $instance;
  4.  
  5. if (!is_object($instance))
  6. {
  7. if ($file === null) {
  8. $file = dirname(__FILE__).DS.'config.php';
  9. }
  10.  
  11. $instance = JFactory::_createConfig($file, $type);
  12. }
  13.  
  14. return $instance;
  15. }
Team Navigation