我想了解如何在joomla 2.5中开发自定义组件,并且在第一步中卡住,我想知道什么是使用assignRef()函数和for更多信息click here什么是joomla 2.5中的assignRef()函数2.5
<?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);
}
}
在assignRef()函数,第一个参数作为变量不是一个值,因为如果我改变它的价值,那么一些其他的事情是不能够显示$问候的值: -
http://docs.joomla.org/Developing_a_Model-View-Controller_Component_-_Part_1 * @license GNU/G PL */
// 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);
}
}
然后在网站/视图/你好/ TMPL /如default.php,如果我写这样的,然后它显示我正确的答案: -
<?php
// No direct access
defined('_JEXEC') or die('Restricted access'); ?>
<h1><?php echo $this->greeting123; ?></h1>
那么结果将是:----你好世界
我知道,对你而言,这是一个简单或天真的问题,但对我来说,这是我自己发展领域的新时代的开始..任何事情都会受到最大的赞赏。 。