Actions

API15

Difference between revisions of "JFactory Class"

From Joomla! Documentation

(New page: I'm a newbie to creating extensions and really wish some info was here, so I'll take a stab at adding what I figure out in hopes of helping others. Access the JFactory using the php code:...)
 
(Remove red links)
 
(9 intermediate revisions by 4 users not shown)
Line 1: Line 1:
I'm a newbie to creating extensions and really wish some info was here, so I'll take a stab at adding what I figure out in hopes of helping others.
+
[[API15:JFactory]]
  
Access the JFactory using the php code:
+
''JFactory'' provides access to a group of core Joomla Objects. In each case it returns an object, usually with the current site settings.
    $var = &JFactory::content();
+
  
Here are a few lines that are included in examples.  They should each be explained.
+
==getApplication()==
  
    $database = &JFactory::getDBO();
+
Returns a reference to the Global [[API15:JApplication]] object
    $document = &JFactory::getDocument();
+
<source lang='php'>$app =& JFactory::getApplication();</source>
  
    $uri = & JFactory::getURI();    
+
==getCache()==
    $id = $row->id;
+
 
Does the above point to the user who is logged in?
+
Returns a reference to the Global [[API15:JCache]] object
 +
<source lang='php'>$cache =& JFactory::getCache();</source>
 +
 
 +
==getConfig()==
 +
 
 +
Returns a reference to the Global JConfig object
 +
<source lang='php'>$config =& JFactory::getConfig();</source>
 +
 
 +
==getDate()==
 +
 
 +
Returns a reference to the Global [[API15:JDate]] object
 +
<source lang='php'>$date =& JFactory::getDate();</source>
 +
 
 +
==getDBO()==
 +
 
 +
Returns a reference to the Global [[API15:JDatabase]] object
 +
<source lang='php'>$db =& JFactory::getDBO();</source>
 +
 
 +
==getDocument()==
 +
 
 +
Returns a reference to the Global [[API15:JDocument]] object
 +
<source lang='php'>$doc =& JFactory::getDocument();</source>
 +
 
 +
==getEditor()==
 +
 
 +
Returns a reference to the Global [[API15:JEditor]] object
 +
<source lang='php'>$editor =& JFactory::getEditor();</source>
 +
 
 +
==getLanguage()==
 +
 
 +
Returns a reference to the Global [[API15:JLanguage]] object
 +
<source lang='php'>$lang =& JFactory::getLanguage();</source>
 +
 
 +
==getMailer()==
 +
 
 +
Returns a reference to the Global [[API15:JMail]] object
 +
<source lang='php'>$mailer =& JFactory::getMailer();</source>
 +
 
 +
==getSession()==
 +
 
 +
Returns a reference to the Global [[API15:JSession]] object
 +
<source lang='php'>$session =& JFactory::getSession();</source>
 +
 
 +
==getTemplate()==
 +
 
 +
Returns a reference to the Global [[API15:JTemplate]] object
 +
<source lang='php'>$template =& JFactory::getTemplate();</source>
 +
 
 +
==getURI()==
 +
 
 +
Returns a reference to the Global [[API15:JURI]] object
 +
<source lang='php'>$uri =& JFactory::getURI();</source>
 +
 
 +
==getUser()==
 +
 
 +
Returns a reference to the Global [[API15:JUser]] object
 +
<source lang='php'>$user =& JFactory::getUser();</source>
 +
 
 +
==getXMLParser()==
 +
 
 +
Returns a reference to the Global JXMLParser object
 +
<source lang='php'>$xmlp =& JFactory::getXMLParser();</source>
 +
Takes parameters: $type & $options
 +
$type can take the values 'DOM' (default), 'RSS', or 'Simple'
 +
$options takes an options array (default is empty)
 +
boolean ['lite'] for use with DOM to use domit_lite (default)
 +
string [#rssUrl'] for use with 'RSS'
 +
string [cache_time'] feed cache time for 'RSS' (default = 3600 seconds)
 +
 
 +
== See Also ==
 +
* [http://api.joomla.org/Joomla-Framework/JFactory.html JFactory class documentation from the Joomla! API]
 +
 
 +
[[Category:Development]]

Latest revision as of 15:08, 4 July 2013

Replacement filing cabinet.png
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.

API15:JFactory

JFactory provides access to a group of core Joomla Objects. In each case it returns an object, usually with the current site settings.

Contents

getApplication()

Returns a reference to the Global API15:JApplication object

$app =& JFactory::getApplication();

getCache()

Returns a reference to the Global API15:JCache object

$cache =& JFactory::getCache();

getConfig()

Returns a reference to the Global JConfig object

$config =& JFactory::getConfig();

getDate()

Returns a reference to the Global API15:JDate object

$date =& JFactory::getDate();

getDBO()

Returns a reference to the Global API15:JDatabase object

$db =& JFactory::getDBO();

getDocument()

Returns a reference to the Global API15:JDocument object

$doc =& JFactory::getDocument();

getEditor()

Returns a reference to the Global API15:JEditor object

$editor =& JFactory::getEditor();

getLanguage()

Returns a reference to the Global API15:JLanguage object

$lang =& JFactory::getLanguage();

getMailer()

Returns a reference to the Global API15:JMail object

$mailer =& JFactory::getMailer();

getSession()

Returns a reference to the Global API15:JSession object

$session =& JFactory::getSession();

getTemplate()

Returns a reference to the Global API15:JTemplate object

$template =& JFactory::getTemplate();

getURI()

Returns a reference to the Global API15:JURI object

$uri =& JFactory::getURI();

getUser()

Returns a reference to the Global API15:JUser object

$user =& JFactory::getUser();

getXMLParser()

Returns a reference to the Global JXMLParser object

$xmlp =& JFactory::getXMLParser();

Takes parameters: $type & $options $type can take the values 'DOM' (default), 'RSS', or 'Simple' $options takes an options array (default is empty) boolean ['lite'] for use with DOM to use domit_lite (default) string [#rssUrl'] for use with 'RSS' string [cache_time'] feed cache time for 'RSS' (default = 3600 seconds)

See Also