Hi,

I found this php code that shows diffrent page on diffrent day - http://www.dynamicdrive.com/forums/showthread.php?t=22499.

----------

<?php
$h
= date('G');
if (
$h<2) {$p=1;}
else if (
$h<4) {$p=2;}
else if (
$h<6) {$p=3;}
...
else if (
$h<22) {$p=11;}
else {
$p=12;}
include(
$p.'.html');
?>

----------

But it doesnt work in Drupal. What I must change and where to put the code? Template or where...

Comments

Whether you include it on a page or in the theme really depends on what exactly you are trying to do, but the simple answer is you can add php to drupal by setting the Input Format of a node to "PHP Code". If you're using D6, you have to enable the PHP input format module first.

_
Don't be a Help Vampire - read and abide the forum guidelines.
If you find my assistance useful, please pay it forward to your fellow drupalers.

You can do this, but this is not common in drupal

<?php
$h
= date('G');
if (
$h<2) {$p=1;}
else if (
$h<4) {$p=2;}
else if (
$h<6) {$p=3;}
...
else if (
$h<22) {$p=11;}
else {
$p=12;}
$path = "/your_path/";
include(
$path.$p.'.html');
?>

Drupal way is to create page in drupal and load that content instead of page. You can use node_load() to load a node object from the database.

Regards,
Suryanto Rachmat
http://rachmat.net

Where can I use node_load() ?
Sorry im now to drupal.

If I add static 11.html to my page this work, but if I add new page in drupal and rename it to 11.html doesnt. Why?

I'm not quite sure what you're doing-- there are no "html" pages in drupal. "pages" are stored in the database as nodes, so I'm not exactly sure what drupal page you are renaming. If you're having trouble with drupal basics like this it seems you have some reading to do: http://drupal.org/getting-started

_
Don't be a Help Vampire - read and abide the forum guidelines.
If you find my assistance useful, please pay it forward to your fellow drupalers.

I want that for example on mondays page monday.html or node/monday shows up in left corner, on tuesdays tuesday.html .... and so on. Can anyone make this script work with drupal?

This is not the way I'd ideally do this, but if you want a quick hack...

You can add the following code as a new "block". Change the numbers after the $p= to the node IDs of the pages you want to load for the particular day.

<?php
$day
= date('w');
if (
$day==0) {$p=1;} //node to show on sunday
else if ($day==1) {$p=22;} //node to show on monday
else if ($day==2) {$p=12;} //node to show on tuesday
else if ($day==3) {$p=6;} //node to show on wednesday
else if ($day==4) {$p=2;} //node to show on thursday
else if ($day==5) {$p=3;} //node to show on friday
else {$p=6;} //node to show on saturday
$n = node_load($p);
print
node_teaser($n->body);
?>

edit: make sure the block input format is set to PHP code

Thanks for help, especially to suryanto who made that this script work on my site.

could have been written like this:

<?php
$h
= date('G');
$p = max(1, min($h / 2, 12));
$path = "/your_path/";
include(
$path.$p.'.html');
?>