Conditional pages

Rating

Sometimes there are pages you only show at certain conditions. 

For example, suppose you want to show a registration form until 10 people have registered. Afterwards this page should not appear and there should be a message that one can not register any more.

The PHP script below shows how simple it is. (A php page can be made with the PHP module)

First we count how many nodes are already in the content type 'booking'. If 10 or more nodes we are showing the number and set the message that one can not register.

If the maximum is not reached, then we go to the registration form.

<?php
$counter = db_query("SELECT count(nid) FROM {node} WHERE type='booking'")->fetchField();

if ($counter>=10){
echo "Totaal : $counter"; 
echo " No booking possible. Full.";
}

else{
header("Location: ../node/add/booking");
}
?>