Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1506
  • Last Modified:

PopUp window in joomla

I am new to joomla CMS. I want to make a pop up small window that appears when some one opens the website - only in the homepage-
I know how to use joomla components and the admin interface. Can anyone tell me what are the steps to do that.
0
pixarksa
Asked:
pixarksa
  • 7
  • 3
1 Solution
 
Jesse MatlockUX EngineerCommented:
The best way to do this is by using an existing extension like rokbox or another 'pop up' script and trigger is on page load, for the homepage only.

Rokbox:
http://www.rocketwerx.com/products/rokbox/overview

Then you'll need to add some code:
1st to 'fix' the issue that some browsers dont have a click event for an anchor element:

if(typeof HTMLElement!='undefined'&&!HTMLElement.prototype.click)
    HTMLElement.prototype.click=function()
    {
        var evt = this.ownerDocument.createEvent('MouseEvents');
        evt.initMouseEvent('click', true, true, this.ownerDocument.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
        this.dispatchEvent(evt);
    }

THEN, add a link in your footer, that uses the standard RokBox syntax, something like so:

<a href="http://mysite.com/images/myimage.png" rel="rokbox[720 404]" title="Title :: Subtitle" id="my_sig" name="sigplaceholder"></a>

Next, create a function to automatically 'click' this link, so to speak, once the page loads:

function showrokbox()
 {    
    document.getElementById('my_sig').click();
 }

Finally, the last piece of code that will go into your index.php is an IF statement to make sure the page is only the homepage that this executes in (replace the ???? with the item ID for your homepage:

<?php if($_REQUEST['Itemid'] == '????' ) : ?>
<script language="javascript" type="text/javascript">
window.onload = showrokbox();
</script>
<?php endif; ?>


You can 'combine' the JS snippets into the IF statement above as well.. totally up to you.. and you can even place the link in the footer of the homepage via a module, etc instead of adding it to the index.php.. :)

Let me know if this helps out.. if so, we can look at optimizing this solution for you.. ;)
0
 
pixarksaAuthor Commented:
Okay, but is there any simpler way to do it ... all what I need is to launch this popup window in the home page. I think I can utilize joomla default components and modules to do so?
0
 
Jesse MatlockUX EngineerCommented:
Here is a working snippet.. to place in the head of your templates index.php. You will need to change the item ID to the ID of your homepage - the most accurate way to find the ID of the page is to add this to your templates index.php so it displays on the screen:
<?php  echo $_REQUEST['Itemid']; ?>

Note: the attached code is using a link ID of 'rok' . So, your link would look something like this:
<a href="images/myimage.png" rel="rokbox[720 404]" title="Title :: Subtitle" id="rok"></a>

This link, along with the code in your index.php page will open the rokbox popup, which I have tested. Of course you will need to install and ENABLE the rokbox plugins - both of them. :D

Hope this helps!
<?php
 if($_REQUEST['Itemid'] == '1' ) : 
?>
<script language="javascript" type="text/javascript">

if(typeof HTMLElement!='undefined'&&!HTMLElement.prototype.click)
    HTMLElement.prototype.click=function()
    {
        var evt = this.ownerDocument.createEvent('MouseEvents');
        evt.initMouseEvent('click', true, true, this.ownerDocument.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
        this.dispatchEvent(evt);
    }

	function showrokbox(){    
	    document.getElementById('rok').click();
	 }
//	window.addEvent(domready, function(){
//		showrokbox();
//	});
	
	
window.addEvent('domready', function(){
 showrokbox();
});

</script>

<?php 
endif; 

Open in new window

0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
Jesse MatlockUX EngineerCommented:
I'm not aware of a 'std' joomla extension that offers this functionality.. you would need to search the Joomla extension directory for that.. :)
0
 
Jesse MatlockUX EngineerCommented:
Here are a couple possible solutions after a quick search through Joomla's Extension Directory

http://extensions.joomla.org/extensions/style-a-design/popups-a-iframes/9738
http://www.dart-creations.com/joomla/joomla-modules/joomla-popin-window.html
http://extensions.joomla.org/extensions/style-a-design/popups-a-iframes/8000

Give those a look and see if one of their demos might fit the need you have :)
0
 
Jesse MatlockUX EngineerCommented:
@pixarksa:

How are those solutions working for you so far? Did you find one that fits your needs or would you like help implementing the custom code into your template?
0
 
pixarksaAuthor Commented:
I am trying these solutions and I will inform you with the results
0
 
Jesse MatlockUX EngineerCommented:
Sounds great... I look forward to good news :)
0
 
pixarksaAuthor Commented:
Thank you ...
0
 
Jesse MatlockUX EngineerCommented:
anytime.. glad we were able to find a solution that worked well for you .. ;) Take care and let me know if you have any other questions :)
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 7
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now