Hey..
Have been trying to do this for a while: the ability to create dynamic pages without the need to install extra modules or being restricted to adding a new blocks which tend to be only available in the left or right columns.
THE THEORY
Blocks are great. But one of the drawbacks is that when a site begins to grow and more content is added, they tend to end up looking like a "kitchen sink" type link-fest. Where the left & right hand columns of blocks start getting very long and unsightly.....
By "kitchen sink"..I mean sites that are just one massive page full of links to everything and anything.
So, by allowing simpletons & newbies like me (who haven't got an expert eye for php or sql) to be able to generate dynamic main page content..(pulling information from the drupal database in the same way blocks do)...it enables us to move away from kitchen sink drupal sites and increasing the ergonomics and useability of a drupal site for visitors.
Thats the theory...and in practice, what I would like to do is kick off a new thread where we could build up some "sliced bread" php snippets repository for newbies like me..
php page snippet that lists all events in your drupal database
To kickstart the idea, here is a simple snippet I created earlier. It's very basic and very simple but it's an attempt at inserting the "upcoming events" listings that the event block generates and putting that into a page.
To implement it...follow these steps.
1. go to CREATE CONTENT - PAGE
2. paste in the following php snippet
3. Check the PHP code filter and Save the page.
<?php
/**
* Creates a list of all the events in your drupal database
* with a link to each event node. inended as a very simple illustration of what can be done.
*
*/
$gigssql = mysql_query("SELECT * FROM event"); // look in the event table in the drupal database
while ($row = mysql_fetch_row($gigssql)) {
$timestamp = $row[2];
$gigdate= date("D M j G:i ", $timestamp); // formats the date of the event
print "<a href=\"node/$row[0]\">more details</a> --¦-- $row[1] --¦-- $gigdate <br />"; // outputs each event on an individual line with a link to more details.
}
?>
Hope that makes sense and nudges others who are as new to sql & php as I am to make the most out of the out-of-the-box drupal download rather than having to install and hack extra modules to get drupal to do what you want to do.
Dub