Welcome to Geeklog, Anonymous Saturday, July 13 2024 @ 05:28 am EDT

Geeklog Forums

World times


Status: offline

trampoline

Forum User
Full Member
Registered: 02/24/06
Posts: 392
I would like to display very simply in a block, times around the world ??
But I can't put php functions in blocks or it seems I can't any idea's ?
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
Quote by: trampoline

But I can't put php functions in blocks


Hmm? PHP blocks, baby!

bye, Dirk
 Quote

Status: offline

trampoline

Forum User
Full Member
Registered: 02/24/06
Posts: 392
Quote by: Dirk

Quote by: trampoline

But I can't put php functions in blocks


Hmm? PHP blocks, baby!

bye, Dirk


Yes, but I am so incredibly thick I could not make it work, I have bought a very fat book on php "PHP 5" by Julie Meloni and am wading through it in my spare time...
Just though I'd ask as my first attempt got nowhere adding functions to custom lib and calling them...
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
Quote by: trampoline

Just though I'd ask as my first attempt got nowhere adding functions to custom lib and calling them...


You would have to be more specific if you expect any help ...

Keep the naming convention in mind. There's also a function phpblock_showrights in your lib-custom.php that you could use to start playing with.

bye, Dirk
 Quote

Status: offline

trampoline

Forum User
Full Member
Registered: 02/24/06
Posts: 392
Thanks, I guess all I want is

New York 17.06
London 12.06
Delhi 07.06

I will look at it all again...

 Quote

Status: offline

trampoline

Forum User
Full Member
Registered: 02/24/06
Posts: 392
so I have this code.... I know it's not quite right
I have created a block phpblock_worldtimes
a function in lib-custom
and it does call the function cos I've had a few lines printed (incorrectly) I have this as the code for the info to be printed...
Text Formatted Code

<?php




function display_time() {
     global $_CONF;
     
$time_new = time() +18000;
$time_london = time() ;
$time_dharam = time() -19800;

$newname ="New York";
$lonname ="London";
$daram ="Dharamsala";

<? echo "$newname"; ?>
<? echo "$time_new"; ?>


<? echo "$lonname"; ?>
<? echo "$time_london"; ?>

<? echo "$daram"; ?>
<? echo "$time_dharam"; ?>
" ;

?>

 


and this as the lib custom code...
Text Formatted Code
function phpblock_worldtime() {
        global $_CONF;
           include_once($_CONF['path_html'] . "/time/time.php");
    return display_time();
}
 Quote

Status: offline

trampoline

Forum User
Full Member
Registered: 02/24/06
Posts: 392
OK by stipping out all functions and doing a simple
This iss called by the code posted here in libcustom.php which in turn is called by the php block...
Text Formatted Code
<?php


function display_time() {echo "this is line" .__LINE__ ;}

?>

 

I get it working but the text appears in the tiop left hand corner of the Frame how do I get this to display in it's block ????
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
You may want to read the FAQ article above again, specifically the bit about not outputting things directly but returning them from the function ...

bye, Dirk
 Quote

Status: offline

uKrease

Forum User
Junior
Registered: 01/30/06
Posts: 24
Location:JHB ZA
rockin
Why make the call to another file which houses the code, just write it into your function in lib-custom.php ?

Text Formatted Code

function phpblock_showtimes() {    
$result = '';
$time_new = time() +18000;
$time_london = time() ;
$time_dharam = time() -19800;

$newname ='New York';
$lonname ='London';
$daram ='Dharamsala';

$result =  $newname .  ' - ' . $time_new . '<br>';
$result .= $lonname .  ' - ' . $time_london . ' <br>';
$result .= $daram .  ' - ' . $time_dharam . '<br>';
return $result;
}
 


Then, create a block with the call to phpblock_showtimes...

I tested that on my site and it worked fine, you`ll just need to play around with the PHP time() function to get the output of the time correctly formatted...

Hope that helps...
 Quote

Status: offline

trampoline

Forum User
Full Member
Registered: 02/24/06
Posts: 392

Oh Thank you so much, I've been struggling,so much with this one
 Quote

All times are EDT. The time is now 05:28 am.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content