...

View Full Version : How can I set this to load on page load with delay?



sfraise
06-11-2010, 09:47 AM
This script displays a link to a registration/login form that loads in a light box for Joomla.
I've been goin nuts trying to figure out how to get this to load on page load with a delay.
Anyone know how to get this done?

<?php
JHTML::_('behavior.mootools');
$document = JFactory::getDocument();
$document->addStyleSheet(JURI::base() . 'media/system/css/modal.css');
$document->addScript(JURI::base() . 'media/system/js/modal.js');
$document->addScriptDeclaration("window.addEvent('domready', function() {SqueezeBox.initialize({});});");
$user = & JFactory::getUser();

$uri = JFactory::getURI();
$url = $uri->toString();
$return = base64_encode($url);

?>
<div id="lbframeid" style="position:absolute;top:1px;left:1px;height:0px;width:0px;overflow:hidden">
<a href="http://www.wowjoomla.com/"><h1>Joomla Login LightBox powered by WowJoomla.com</h1> </a>
</div>
<?php if ($user->get('guest')) :?>
<a href="<?php echo JRoute::_('index.php?option=com_loginbox')?>"
onclick="SqueezeBox.fromElement(this); return false;"
rel="{handler: 'iframe', size: {x: 660, y: 500}}"><?php echo JText::_('SIGNUP_LOGIN')?></a>
<?php else: ?>
<?php echo JText::sprintf( 'HINAME', $user->get('name') ); ?>
<br>
<a href="javascript:void(0);" onclick="LB_onLogout(); return false;"><?php echo JText::_('LOGOUT')?></a>
<?php endif; ?>
<script type="text/javascript">
function LB_onLogout() {
var form = new Element('form');
form.setProperty('method', 'POST');
form.setProperty('target', '_self');
form.setProperty('action', 'index.php');

var input = new Element('input');
input.setProperty('type', 'hidden');
input.setProperty('name', 'option');
input.setProperty('value', 'com_user');
form.appendChild(input);

var input = new Element('input');
input.setProperty('type', 'hidden');
input.setProperty('name', 'task');
input.setProperty('value', 'logout');
form.appendChild(input);

var input = new Element('input');
input.setProperty('type', 'hidden');
input.setProperty('name', 'return');
input.setProperty('value', '<?php echo $return; ?>');
form.appendChild(input);

$E('body').appendChild(form);
form.submit();
}
</script>

Fou-Lu
06-11-2010, 06:39 PM
You want the entire page to delay? Use sleep($iNumSeconds) at the start to delay processing. If this isn't what your wanting, use JS to delay.

sfraise
06-11-2010, 08:40 PM
Thanks for the reply,

Here's the dilemma..
I tried using js to delay, but the problem is it always brings up the form in a full page instead of in the lightbox.

I thought about adding a sleep() to the php script it's self, but I'm not real sure how to get it to trigger the action on page load instead of just displaying a link as it is now. I tried changing the onclick to onload but it doesn't work, I guess I need to maybe add some js to the header to get it to work that way?

Fou-Lu
06-11-2010, 11:35 PM
If you are intending an onload delay, thats js. PHP can only delay processing, it does not care about anything that happens before or after the processing (such as events).
Anything browser based (layouts, colour, events, etc) are all client side technologies, and are resolved with html, css, js, flash, etc. PHP can make the source, but it sounds like a JS issue to me.

sfraise
06-12-2010, 03:30 AM
Ok, so js is the way to go, which is the way I had originally tried, now I just need to figure out how to get the lightbox to trigger instead of just loading up a whole new window.

Fou-Lu
06-12-2010, 06:00 AM
I'll move this to the JS forum.

sfraise
06-14-2010, 08:13 AM
Thanks.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum