如何在 Joomla 中使用 JHTML::_('behavior.modal')? [英] how to use JHTML::_('behavior.modal') in Joomla?

查看:16
本文介绍了如何在 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')?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆