27 July 2009 Comments

An example of design a Popup Window in Joomla!


写一个用于Joomla里的(超级简单的)pop up window程序。
Like the “lightbox” effect

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
defined( '_JEXEC' ) or die( 'Restricted access' );

jimport('joomla.application.component.controller');

class JsController extends JController {
function modalBox()  {

JHTML::_('behavior.modal', 'a.popup');

?>
<a class="popup" href="index.php?option=com_js&amp;task=insideModal&amp;format=raw">Read the daily menu.</a>
}

function insideModal()
{
?&gt;
<h1>Today's Menu</h1>
<ul>
   <li>Crispy chicken nuggets with ginger dressing</li>
   <li>Swordfish in bean curd sauce</li>
   <li>Stir-fried vegetables over white rice</li>
</ul>
}

}

$controller = new JsController();
$controller-&gt;execute(JRequest::getCmd('
task'));

Let’s try it by going to:

/index.php?option=com_js&task=modalBox

Fresh and Local-1.png
popup.png

如果我们修改一下 modalBox function,

1
2
3
4
5
6
7
8
9
10
function modalBox()  {

$params = array(
'size' =&gt; array(
'x' =&gt; 350,
'y' =&gt; 100
)
);

JHTML::_('behavior.modal', 'a.popup',$params);

用这个我们就可以控制弹出窗口的大小了。

blog comments powered by Disqus