Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

Joomla pre loader

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Joomla pre loader

Postby KaanTuncer » Thu Mar 24, 2011 1:54 pm

Dear friends,

I have a website built using joomla. The website works great but takes a long time before it is loaded. What you see is a white screen for a long time and after a while the website will load. I would like here to make a small preloader so people have something to see while they wait. But when I build a pre loader in my index.php of my site, I get issues with the session.php. I have already understood that I cannot drop anything before the start of the PHP code, but the question is how can i build a pre loader in my joomla website?

This is my index.php (without pre loader also without errors):


Code: Select all
<?php
/**
* @version      $Id: index.php 14401 2010-01-26 14:10:00Z louis $
* @package      Joomla
* @copyright   Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved.
* @license      GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/
// Set flag that this is a parent file
define( '_JEXEC', 1 );

define('JPATH_BASE', dirname(__FILE__) );

define( 'DS', DIRECTORY_SEPARATOR );

require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );

JDEBUG ? $_PROFILER->mark( 'afterLoad' ) : null;

/**
 * CREATE THE APPLICATION
 *
 * NOTE :
 */
$mainframe =& JFactory::getApplication('site');

/**
 * INITIALISE THE APPLICATION
 *
 * NOTE :
 */
// set the language
$mainframe->initialise();

JPluginHelper::importPlugin('system');

// trigger the onAfterInitialise events
JDEBUG ? $_PROFILER->mark('afterInitialise') : null;
$mainframe->triggerEvent('onAfterInitialise');

/**
 * ROUTE THE APPLICATION
 *
 * NOTE :
 */
$mainframe->route();

// authorization
$Itemid = JRequest::getInt( 'Itemid');
$mainframe->authorize($Itemid);

// trigger the onAfterRoute events
JDEBUG ? $_PROFILER->mark('afterRoute') : null;
$mainframe->triggerEvent('onAfterRoute');

/**
 * DISPATCH THE APPLICATION
 *
 * NOTE :
 */
$option = JRequest::getCmd('option');
$mainframe->dispatch($option);

// trigger the onAfterDispatch events
JDEBUG ? $_PROFILER->mark('afterDispatch') : null;
$mainframe->triggerEvent('onAfterDispatch');

/**
 * RENDER  THE APPLICATION
 *
 * NOTE :
 */
$mainframe->render();

// trigger the onAfterRender events
JDEBUG ? $_PROFILER->mark('afterRender') : null;
$mainframe->triggerEvent('onAfterRender');

/**
 * RETURN THE RESPONSE
 */
echo JResponse::toString($mainframe->getCfg('gzip'));
?>



This is my index.php (with pre loader and errors):

Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<SCRIPT TYPE="text/javascript" LANGUAGE="javascript">

<!-- PreLoad Wait - Script -->
<!-- This script and more from http://www.rainbow.arch.scriptmania.com

function waitPreloadPage() { //DOM
if (document.getElementById){
document.getElementById('prepage').style.visibility='hidden';
}else{
if (document.layers){ //NS4
document.prepage.visibility = 'hidden';
}
else { //IE4
document.all.prepage.style.visibility = 'hidden';
}
}
}
// End -->
</SCRIPT>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />


<meta name="keywords" content="Xgadget.nl" />
<meta name="description" content="Xgadget.nl" />
<meta name="title" content="Xgadget.nl" />
<meta name="designer" content="DesignDelivery, info@designdelivery.nl" />
<meta name="author" content="DesignDelivery, info@designdelivery.nl" />
<meta name="copyright" content="Copyright 2011, Xgadget.nl" />
 
<title>Xgadget.nl</title>

</head>

<body onLoad="waitPreloadPage();">
<DIV id="prepage" style="position:absolute; font-family:arial; font-size:16; left:0px; top:0px; background-color:white; layer-background-color:white; height:100%; width:100%;">
<TABLE width=100%><TR><TD><B>Loading ... ... Please wait!</B></TD></TR></TABLE>
</DIV>
<?php
/**
* @version      $Id: index.php 14401 2010-01-26 14:10:00Z louis $
* @package      Joomla
* @copyright   Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved.
* @license      GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/
// Set flag that this is a parent file
define( '_JEXEC', 1 );

define('JPATH_BASE', dirname(__FILE__) );

define( 'DS', DIRECTORY_SEPARATOR );

require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );

JDEBUG ? $_PROFILER->mark( 'afterLoad' ) : null;

/**
 * CREATE THE APPLICATION
 *
 * NOTE :
 */
$mainframe =& JFactory::getApplication('site');

/**
 * INITIALISE THE APPLICATION
 *
 * NOTE :
 */
// set the language
$mainframe->initialise();

JPluginHelper::importPlugin('system');

// trigger the onAfterInitialise events
JDEBUG ? $_PROFILER->mark('afterInitialise') : null;
$mainframe->triggerEvent('onAfterInitialise');

/**
 * ROUTE THE APPLICATION
 *
 * NOTE :
 */
$mainframe->route();

// authorization
$Itemid = JRequest::getInt( 'Itemid');
$mainframe->authorize($Itemid);

// trigger the onAfterRoute events
JDEBUG ? $_PROFILER->mark('afterRoute') : null;
$mainframe->triggerEvent('onAfterRoute');

/**
 * DISPATCH THE APPLICATION
 *
 * NOTE :
 */
$option = JRequest::getCmd('option');
$mainframe->dispatch($option);

// trigger the onAfterDispatch events
JDEBUG ? $_PROFILER->mark('afterDispatch') : null;
$mainframe->triggerEvent('onAfterDispatch');

/**
 * RENDER  THE APPLICATION
 *
 * NOTE :
 */
$mainframe->render();

// trigger the onAfterRender events
JDEBUG ? $_PROFILER->mark('afterRender') : null;
$mainframe->triggerEvent('onAfterRender');

/**
 * RETURN THE RESPONSE
 */
echo JResponse::toString($mainframe->getCfg('gzip'));
?>
</body>
</html>




Errors that arise with this code:


Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/users/xgadgftp/xgadget.nl/index.php:41) in /home/users/xgadgftp/xgadget.nl/libraries/joomla/session/session.php on line 423

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/users/xgadgftp/xgadget.nl/index.php:41) in /home/users/xgadgftp/xgadget.nl/libraries/joomla/session/session.php on line 423

Warning: Cannot modify header information - headers already sent by (output started at /home/users/xgadgftp/xgadget.nl/index.php:41) in /home/users/xgadgftp/xgadget.nl/libraries/joomla/session/session.php on line 426

Warning: Cannot modify header information - headers already sent by (output started at /home/users/xgadgftp/xgadget.nl/index.php:41) in /home/users/xgadgftp/xgadget.nl/templates/ja_purity/ja_templatetools.php on line 44


My question is how do I create a pre loader for a website based on joomla without the errors?

Sincerely

kaan
KaanTuncer
New php-forum User
New php-forum User
 
Posts: 1
Joined: Thu Mar 24, 2011 1:44 pm

Re: Joomla pre loader

Postby johnj » Thu Mar 24, 2011 8:19 pm

In this case there are two events - something happens before the page is loaded (i.e. display of the text 'please wait....') and something else has to happen after the homepage has loaded (i.e. display the home page). One way to achieve this is - In JQuery there is a function called document.ready(). You may want to look into that and use that to cater the two events that I have mentioned.
http://docs.jquery.com/Tutorials:Introd ... eady%28%29
johnj
php-forum Super User
php-forum Super User
 
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Re: Joomla pre loader

Postby traposfriend » Sun Nov 24, 2013 3:28 pm

You can try using this plugin: http://emkt.mx/joomla-website-preloader-plugin.html
It's a Joomla Website Preloader plugin.
I think it can help you. :)
traposfriend
New php-forum User
New php-forum User
 
Posts: 1
Joined: Sun Nov 24, 2013 3:18 pm


Return to PHP coding => General

Who is online

Users browsing this forum: Google [Bot] and 5 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.