Joomla popup button

Joomla 1.5 has a nice pop up button class. This will dim the webpage and popup a smaller page over it. I found that it doesn’t work quite right outside a toolbar, so here’s how to manually do it.

First we must load the modal behavior. Take note that in the examples I split some code over multiple lines for display purposes in the article.

JHTML::_('behavior.modal');

Then simply put in this link with the information you want.

<a href="http://www.google.com'" mce_href="http://www.google.com'"
    rel="{handler: 'iframe', size: {x: 500, y: 400}}">
        <span title="<some title>">
            <img src="<path to image file>" border="0" name="<name>" title="<title>" alt="<alt text>" />
        </span>
</a>

You can even combine this with tooltips! Of course you must load the proper behavior.

 JHTML::_('behavior.tooltip');

Then put in this link.

<a href="http://www.google.com'" mce_href=http://www.google.com'/
    rel="{handler: 'iframe', size: {x: 500, y: 400}}">
        <span title="tip title::tip text">
            <img src="<path to image file>" border="0" name="<name>" title="<title>" alt="<alt text>" />
        </span>
</a>

Now to make this more useful, what if you wanted to load some code from a view? This example calls a function in a view to display the page. Here’s the function.

function displayPopup() {
 ?>
 <!-- The HTML for the page goes here. -->
<?php
}

We can call this function using the controller.

function popup() {
 	$view = & $this->getView('<view name>', 'html');

	// Get/Create the model
	$model = & $this->getModel('<model name>');

	// Push the model into the view (as default)
	$view->setModel($model, true);

	// Display the view
	$view->displayPopup();
}

Now here is the link that could trigger this popup. This assumes that you are using $task to trigger methods in your controller. Take note that the last tmpl=component should appear exactly as that. This makes the popup be only the code you put in the view.

$mainframe->getCfg('live_site').'/index.php?option=<your component>&
controller=<controller if no default>&task=popup&tmpl=component

About Adam Oliver

Adam Oliver has been working in the IT field for over 10 years. Currently he is employed by triCerat, Inc. solving printing and profile management issues for a variety of clients.
This entry was posted in Web Development and tagged , , . Bookmark the permalink.

2 Responses to Joomla popup button

  1. _vesna says:

    it was very interesting to read wordpress.aikidokatech.com
    I want to quote your post in my blog. It can?
    And you et an account on Twitter?

    Author response: You are more than welcome to quote the article. I just ask you link back to it with the quote. At this time I do not have a twitter account.

  2. Allan says:

    I got the modal to work using the iframe. Do you Know how to popup a div. If so can you post an example. Thanx

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>