本文介绍了如何在Joomla中使用JHTML :: _('behavior.modal')?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在创建一个组件,
controllers
theatercontroller
facilitycontroller
Models
theater
facility
view
theater
facility
我想要的是通过单击按钮并打开模式窗口从剧院视图添加新设施.我已经尝试过,但是没有用.我研究了一些组件,但是像我这样的人很难理解.请我需要一个简单的例子和一个解释来理解它.
What I want is I want to add a new facility from the theater view by clicking a button and opening a modal window. I have tried but didn't work. I studied some components but it is difficult for someone like me to understand it. Please I need a simple example and a explanation to understand it.
推荐答案
您可以使用此功能获取模式按钮
You can use this function to get a modal button
static public function getModalButtonObject($name,$text,$link,$width=750,$height=480)
{
JHTML::_('behavior.modal', "a.{$name}"); // load the modal behavior for the name u given
$buttonMap = new JObject(); // create an Jobject which will contain some data, it is similar like stdClass object
$buttonMap->set('modal', true);
$buttonMap->set('text', $text );
$buttonMap->set('name', 'image');
$buttonMap->set('modalname', $name);
$buttonMap->set('options', "{handler: 'iframe', size: {x: ".$width.", y: ".$height."}}");
$buttonMap->set('link', $link);
return $buttonMap;
}
HTML可以写为
<a id="<?php echo $buttonMap->modalname; ?>" class="<?php echo $buttonMap->modalname; ?>" title="<?php echo $buttonMap->text; ?>" href="<?php echo $buttonMap->link; ?>" rel="<?php echo $buttonMap->options; ?>"><?php echo $buttonMap->text; ?></a>
这篇关于如何在Joomla中使用JHTML :: _('behavior.modal')?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!