Please login or register.

Login with username, password and session length
Advanced search  

News:

You need/want an older version of sNews ? Download an older/unsupported version here.

Author Topic: [Mini-MOD] page generation time in footer  (Read 1583 times)

henrich

  • Sr. Member
  • ****
  • Karma: 23
  • Posts: 381
  • Passion for quality and excellence!
    • My personal blog and portofolio
[Mini-MOD] page generation time in footer
« on: January 22, 2008, 07:39:54 pm »

Hi again  :-\,

As you know already, i use plenty MODs and ADDONs from this forum but sometimes i need new features that i need to write them myself, or to get from an existing MOD and modify it to my needs. Some of them have good look effects to the site, others are bringing good functionalities.

The current will measure the page generation time. Useful for site builders for testing, improoving page generation time and also for the online sites. I took the timer code from here (with postme's permission, Thank you postme!) http://snewscms.com/forum/index.php?topic=6607.msg44937#msg44937 and i have written some steps to show you how can you use this piece of code for testing purpose or for normal use.



Step 1. Create a directory called mods. If already exists, then it is okay.
Step 2. In the mods directory create another directory, called timer.
Step 3. New php file creation:

Code: [Select]
<?php

$stimer 
explode' 'microtime() );
$stimer $stimer[1] + $stimer[0];

?>

Save it as start.php and save it into the timer directory.

You will have:

mods/timer/start.php

Step 4. Another file must be created:

Code: [Select]
<?php

$etimer 
explode' 'microtime() );
$etimer $etimer[1] + $etimer[0];
echo 
'<p align="center">';
 
printf(l('page_timer').": <b>%f</b> ".l('seconds'), ($etimer-$stimer) );
echo 
'</p>';

?>

Save this file as end.php in the timer directory.

You will have:

mods/timer/end.php

Step 5. Add 2 new language variables to the language variables list:

Code: [Select]
$l['page_timer'] = 'Page generation time';
$l['seconds'] = 'seconds';

Step 6. In the root directory into the index.php file add blue line:

session_start();
include_once('mods/timer/start.php');
include('config.php');

NOTE: I have added already the "Template Switcher" MOD from bakercad!

Step 7. In the template file, before the </body> tag you can add the following code:

Code: [Select]
<div class="timer">
<?php include_once('mods/timer/end.php'); ?>
</div>

Step 8. Class for the step 7:

Code: [Select]
.timer {
background : #ffffff;
margin : 0px auto 0px auto;
width : 950px;
clear : both;
height : 15px;
font : normal 11px Verdana;
color : #808080;
}

NOTE: Of course this you will customise regarding your needs :)



This is it, thanks for reading my new post, no comments are required, i know that my first mods are not too important, but as i said already, i need them, i use them and i was thought to share them here on the forum, a place what i like very much for it's community :D

Logged
By(e) Henrich :)
------------------------------
IT related blog