why JController costruttor is function __construct( $config = array() ) ? and not function JController( $config = array() ) ?
and than what 's the function of $config = array()? it's not very clear.
controller
-
- Joomla! Intern
- Posts: 62
- Joined: Tue May 06, 2008 7:20 am
- Location: Italia - Treviso
- Contact:
controller
w joomla
- pe7er
- Joomla! Master
- Posts: 24977
- Joined: Thu Aug 18, 2005 8:55 pm
- Location: Nijmegen, Netherlands
- Contact:
Re: controller
[MOD note: moving from Joomla! 1.5.x_Dev to Joombie Coding Q/A]
Kind Regards,
Peter Martin, Global Moderator
Company website: https://db8.nl/en/ - Joomla specialist, Nijmegen, Netherlands
The best website: https://the-best-website.com
Peter Martin, Global Moderator
Company website: https://db8.nl/en/ - Joomla specialist, Nijmegen, Netherlands
The best website: https://the-best-website.com
-
- Joomla! Intern
- Posts: 62
- Joined: Tue May 06, 2008 7:20 am
- Location: Italia - Treviso
- Contact:
-
- Joomla! Enthusiast
- Posts: 146
- Joined: Tue Nov 08, 2005 9:32 am
- Location: Malaysia
Re: controller
Hi,
__construct is the PHP5 version of constructors. See here:
http://my.php.net/manual/en/language.oop5.decon.php
All constructors in Joomla 1.5 are like this. It is compatible with PHP4 though.
As for the $config array, it allows you to set some of the parameters of your controller: from the code of
libraries/joomla/application/component/controller.php:
So if you pass an array:
- $config['name'] = thatsMyName; // Name of the controller is thatsMyName
- $config['default_task'] = editTask; // Task is editTask if not specified (default would be display)
etc...
If your $config array is empty, you will get the default values
Hope this helps
__construct is the PHP5 version of constructors. See here:
http://my.php.net/manual/en/language.oop5.decon.php
All constructors in Joomla 1.5 are like this. It is compatible with PHP4 though.
As for the $config array, it allows you to set some of the parameters of your controller: from the code of
libraries/joomla/application/component/controller.php:
Code: Select all
//set the view name // <- probably a typo, should be set the controller name
if (empty( $this->_name ))
{
if (array_key_exists('name', $config)) {
$this->_name = $config['name'];
} else {
$this->_name = $this->getName();
}
}
// Set a base path for use by the controller
if (array_key_exists('base_path', $config)) {
$this->_basePath = $config['base_path'];
} else {
$this->_basePath = JPATH_COMPONENT;
}
// If the default task is set, register it as such
if ( array_key_exists( 'default_task', $config ) ) {
$this->registerDefaultTask( $config['default_task'] );
} else {
$this->registerDefaultTask( 'display' );
}
// set the default model search path
if ( array_key_exists( 'model_path', $config ) ) {
// user-defined dirs
$this->addModelPath($config['model_path']);
} else {
$this->addModelPath($this->_basePath.DS.'models');
}
// set the default view search path
if ( array_key_exists( 'view_path', $config ) ) {
// user-defined dirs
$this->_setPath( 'view', $config['view_path'] );
} else {
$this->_setPath( 'view', $this->_basePath.DS.'views' );
}
- $config['name'] = thatsMyName; // Name of the controller is thatsMyName
- $config['default_task'] = editTask; // Task is editTask if not specified (default would be display)
etc...
If your $config array is empty, you will get the default values
Hope this helps
-
- Joomla! Intern
- Posts: 62
- Joined: Tue May 06, 2008 7:20 am
- Location: Italia - Treviso
- Contact:
Re: controller
thanks 1000000000000..........
now is very clear.
I like to develop with joomla and I am studying the framewrok. is correct?
now is very clear.
I like to develop with joomla and I am studying the framewrok. is correct?
w joomla
-
- Joomla! Enthusiast
- Posts: 146
- Joined: Tue Nov 08, 2005 9:32 am
- Location: Malaysia
Re: controller
Hi,
studying the framework might give you a headache
Maybe you should consider the tutorials on MVC development.
Also a good idea would be to look at (or even to base your new components on) the com_weblinks (admin side). It's in my opinion the most MVC component on the Joomla basic installation. Really helps.
Have fun!
studying the framework might give you a headache
Maybe you should consider the tutorials on MVC development.
Also a good idea would be to look at (or even to base your new components on) the com_weblinks (admin side). It's in my opinion the most MVC component on the Joomla basic installation. Really helps.
Have fun!