将数据从 joomla 视图传递到 joomla 1.7 中的 joomla 模板文件
我想知道如何将数据从 joomla 视图传递到 joomla 模板。如何传递多个变量?
class CareerformViewCareerform extends JView
{
protected $state;
protected $item;
function display($tpl = null)
{
$app = JFactory::getApplication();
$params = $app->getParams();
// Get some data from the models
$state = $this->get('State');
$item = $this->get('Item');
$newvar="Something";
$success_message="Thanks for your interest";
parent::display($tpl);
}
}
我想将 $newvar
和 $success_message
传递给模板;我怎样才能通过它们?
I want to know how can I pass data from joomla view to joomla template. How can I pass multiple variables?
class CareerformViewCareerform extends JView
{
protected $state;
protected $item;
function display($tpl = null)
{
$app = JFactory::getApplication();
$params = $app->getParams();
// Get some data from the models
$state = $this->get('State');
$item = $this->get('Item');
$newvar="Something";
$success_message="Thanks for your interest";
parent::display($tpl);
}
}
I want to pass $newvar
and $success_message
to template; how can I pass them?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我们可以使用以下方法将视图数据传递到模板:
请注意,
assignRef
通过引用传递第二个参数,我们不仅可以将其检索为$var1
,还可以将其检索为$this- >var1
We can pass view data to template by using:
Please note that
assignRef
pass second param by reference and we can retrieve it asnot just
$var1
but$this->var1