Using the JFactory class: Difference between revisions
From Joomla! Documentation
Creation of JFactory class usage Boilerplate WIP -- 2017-03-15 |
m Improve design - Links rewritten... (Yves, look, for once I'm useful) |
||
| Line 1: | Line 1: | ||
{{version | {{Top portal heading|color=white-bkgd|icon=magic|icon-color=#5091cd|size=3x|text-color=#333|title=Tutorial<br /> | ||
Using the JFactory Class}} | |||
<noinclude>{{Joomla version|version=3.0|time=and after|comment=<series}}</noinclude> | |||
{{-}} | |||
== Introduction == | == Introduction == | ||
JFactory is the Joomla Platform class, giving you access to the most important (mostly singletons) parts in Joomla. It contains multiple other objects, like the application one or the Joomla! global configuration. | JFactory is the Joomla! Platform class, giving you access to the most important (mostly singletons) parts in Joomla. It contains multiple other objects, like the application one or the Joomla! global configuration. | ||
== JFactory::getApplication() == | == JFactory::getApplication() == | ||
| Line 8: | Line 11: | ||
Returns the JApplicationCMS, through it you can access for the example do redirects, access the configuration and the input variables, the Menu or enqueue messages which are shown to the user. | Returns the JApplicationCMS, through it you can access for the example do redirects, access the configuration and the input variables, the Menu or enqueue messages which are shown to the user. | ||
See [[Using the JApplication class]] for more details. | *See [[S:MyLanguage/Using the JFactory class/Using the JApplication class|Using the JApplication class]] for more details. | ||
== JFactory::getDocument() == | == JFactory::getDocument() == | ||
| Line 14: | Line 17: | ||
Provides access to the current JDocument, with it you can set Meta data, add styles and scripts and more related to the document. | Provides access to the current JDocument, with it you can set Meta data, add styles and scripts and more related to the document. | ||
See [[Adding JavaScript and CSS to the page]] | *See [[S:MyLanguage/Using the JFactory class/Adding JavaScript and CSS to the page|Adding JavaScript and CSS to the page]] | ||
== JFactory::getDbo() == | == JFactory::getDbo() == | ||
Returns a database object, with it you query to the database ($query = JFactory::getDbo()->getQuery(true)), secure your input before sending it and load entries. | Returns a database object, with it you query to the database <tt>($query = JFactory::getDbo()->getQuery(true))</tt>, secure your input before sending it and load entries. | ||
See also [[Selecting data using JDatabase]] | *See also [[S:MyLanguage/Using the JFactory class/Selecting data using JDatabase|Selecting data using JDatabase]] | ||
== JFactory::getUser() == | == JFactory::getUser() == | ||
| Line 26: | Line 29: | ||
Returns the current Joomla! user object (JUser), with it you can access information and methods related to users. It is also created for guests, where the id is zero. | Returns the current Joomla! user object (JUser), with it you can access information and methods related to users. It is also created for guests, where the id is zero. | ||
See [[Accessing the current user object]] | *See [[S:MyLanguage/Using the JFactory class/Accessing the current user object|Accessing the current user object]] | ||
== JFactory::getDate() == | == JFactory::getDate() == | ||
Returns a [[How to use JDate]] instance, you can also add a time and a timezone offset to it. Without parameters it uses the current time. | Returns a [[S:MyLanguage/Using the JFactory class/How to use JDate|How to use JDate]] instance, you can also add a time and a timezone offset to it. Without parameters it uses the current time. | ||
== JFactory::getMailer() == | == JFactory::getMailer() == | ||
| Line 36: | Line 39: | ||
Provides access to the Joomla Mailer (wrapper around PHPMailer) for sending emails with Joomla. | Provides access to the Joomla Mailer (wrapper around PHPMailer) for sending emails with Joomla. | ||
See also [[Sending email from extensions]] | *See also [[Sending email from extensions]] | ||
== JFactory::getConfig() == | == JFactory::getConfig() == | ||
Returns a registry with the Joomla! configuration file (configuration.php), see [[JConfig]] for more details. To access single values you can use JFactory::getApplication()->get('configValue') | Returns a registry with the Joomla! configuration file (configuration.php), see [[S:MyLanguage/Using the JFactory class/JConfig|JConfig]] for more details. To access single values you can use <tt>JFactory::getApplication()->get('configValue')</tt> | ||
See also [[Getting global configuration parameters]] | *See also [[S:MyLanguage/Using the JFactory class/Getting global configuration parameters|Getting global configuration parameters]] | ||
== JFactory::getSession() == | == JFactory::getSession() == | ||
Returns the current visitors session. (Make sure Joomla is called as Webapplication) | Returns the current visitors session. (Make sure Joomla! is called as Webapplication) | ||
== External Links == | == External Links == | ||
| Line 52: | Line 55: | ||
[https://api.joomla.org/cms-3/classes/JFactory.html API Docs for JFactory] | [https://api.joomla.org/cms-3/classes/JFactory.html API Docs for JFactory] | ||
<noinclude> | |||
[[Category:JFactory]] | [[Category:JFactory]] | ||
[[Category:Tutorials]][[Category:Framework]] | [[Category:Tutorials]][[Category:Framework]] | ||
[[Category:Module Development]] | [[Category:Module Development]] | ||
[[Category:Plugin Development]][[Category:Component Development]] | [[Category:Plugin Development]] | ||
[[Category:Component Development]] | |||
</noinclude> | |||
Revision as of 00:40, 16 March 2017
Using the JFactory Class
Introduction
JFactory is the Joomla! Platform class, giving you access to the most important (mostly singletons) parts in Joomla. It contains multiple other objects, like the application one or the Joomla! global configuration.
JFactory::getApplication()
Returns the JApplicationCMS, through it you can access for the example do redirects, access the configuration and the input variables, the Menu or enqueue messages which are shown to the user.
- See Using the JApplication class for more details.
JFactory::getDocument()
Provides access to the current JDocument, with it you can set Meta data, add styles and scripts and more related to the document.
JFactory::getDbo()
Returns a database object, with it you query to the database ($query = JFactory::getDbo()->getQuery(true)), secure your input before sending it and load entries.
- See also Selecting data using JDatabase
JFactory::getUser()
Returns the current Joomla! user object (JUser), with it you can access information and methods related to users. It is also created for guests, where the id is zero.
JFactory::getDate()
Returns a How to use JDate instance, you can also add a time and a timezone offset to it. Without parameters it uses the current time.
JFactory::getMailer()
Provides access to the Joomla Mailer (wrapper around PHPMailer) for sending emails with Joomla.
- See also Sending email from extensions
JFactory::getConfig()
Returns a registry with the Joomla! configuration file (configuration.php), see JConfig for more details. To access single values you can use JFactory::getApplication()->get('configValue')
JFactory::getSession()
Returns the current visitors session. (Make sure Joomla! is called as Webapplication)