i am trying to understand about how to develop custom components in joomla 2.5 and on the very first step i get stuck and i want to know what is the use assignRef() function and for more info click here
<?php
/**
* @package Joomla.Tutorials
* @subpackage Components
* @link http://docs.joomla.org/Developing_a_Model-View-Controller_Component_-_Part_1
* @license GNU/GPL
*/
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
jimport( 'joomla.application.component.view');
/**
* HTML View class for the HelloWorld Component
*
* @package HelloWorld
*/
class HelloViewHello extends JView
{
function display($tpl = null)
{
$greeting = "Hello World!";
$this->assignRef( 'greeting', $greeting );
parent::display($tpl);
}
}
In assignRef() function, the first parameter acts as variable not a value because if i am changing it's value to some other thing then it is not able to showing the value of $greeting:-
http://docs.joomla.org/Developing_a_Model-View-Controller_Component_-_Part_1 * @license GNU/GPL */
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
jimport( 'joomla.application.component.view');
/**
* HTML View class for the HelloWorld Component
*
* @package HelloWorld
*/
class HelloViewHello extends JView
{
function display($tpl = null)
{
$greeting = "Hello World!";
$this->assignRef( 'greeting123', $greeting );
parent::display($tpl);
}
}
then in site/views/hello/tmpl/default.php, if i write like these then it is showing me the correct answer:-
<?php
// No direct access
defined('_JEXEC') or die('Restricted access'); ?>
<h1><?php echo $this->greeting123; ?></h1>
Then the result will be:---- Hello world
I know that for you it's been a simple or a naive question but for me it's the beginning of a new era in my own development field..Anything will be appreciated the most..