Views Notwithstanding: A programmer's guide to working with MySQL Tables in Drupal using SQL and PHP.
If you know SQL and PHP but are new to Drupal programming, this presentation is for you.
We will build Hot Or Not – a simple block that presents a few pictures and asks viewers to indicate whether it is hot or not – just as in the movie The Social Network. Since we are the programmers, we will need to populate the list of pictures too. We will put all the pictures in a folder. We will build an admin interface to automatically read in all the files and populate the database of available pictures. We will also create an “admin” interface to add a title and description to these pictures. Next we will create a “Block” to display the pictures, and allow viewers to indicate whether the picture is Hot or Not. We will ensure that the user does not have to rate the same picture twice, by storing his preference in the table.
We will do this by making use of a few basic Drupal APIs and methodologies:
1. Creating a Custom Module
2. Adding Custom Tables
3. Adding additional Tables
4. Adding an Admin Menu
5. Forms API
I will demo the working version first, and do a code overview. If time permits, I will attempt to build the module from scratch.
We will do all this, WITHOUT using VIEWS.
- Login to post comments