Sar*_*ara 0 joomla joomla1.5 joomla-extensions
我正在创建一个组件,
controllers
theatercontroller
facilitycontroller
Models
theater
facility
view
theater
facility
Run Code Online (Sandbox Code Playgroud)
我想要的是我想通过点击按钮并打开模态窗口从影院视图中添加新设施.我尝试过但没有奏效.我研究了一些组件,但像我这样的人很难理解它.我需要一个简单的例子和解释来理解它.
Bre*_*iar 14
它不一定非常复杂.许多模板已经打开了模态行为,但是如果它们不是全部你需要做的就是将它添加到头部 -
<?php JHTML::_('behavior.modal'); ?>
Run Code Online (Sandbox Code Playgroud)
然后将其添加到要在模态窗口中打开的任何链接 -
class="modal"
Run Code Online (Sandbox Code Playgroud)
其他一切都是可选的.
您可以使用此功能获取模态按钮
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;
}
Run Code Online (Sandbox Code Playgroud)
而 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>
Run Code Online (Sandbox Code Playgroud)