27 July 2009 View Comments

An example of design a Popup Window in Joomla!


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

[cc lang="php" line_numbers="true"]
defined( ‘_JEXEC’ ) or die( ‘Restricted access’ );

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

class JsController extends JController {
function modalBox() {

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

?>
Read the daily menu.
}

function insideModal()
{
?>

Today’s Menu

  • Crispy chicken nuggets with ginger dressing
  • Swordfish in bean curd sauce
  • Stir-fried vegetables over white rice

}

}

$controller = new JsController();
$controller->execute(JRequest::getCmd(’task’));
[/cc]

Let’s try it by going to:

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

Fresh and Local-1.png
popup.png

如果我们修改一下 modalBox function,

[cc lang="php" line_numbers="true"]
function modalBox() {

$params = array(
’size’ => array(
‘x’ => 350,
‘y’ => 100
)
);

JHTML::_(’behavior.modal’, ‘a.popup’,$params);
[/cc]

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

blog comments powered by Disqus