Create a Better Photo Gallery in Drupal - Part 2
17th August 2010
Warning: This post is over a year old. I don't always update old posts with new information, so some of this information may be out of date.
At the end of my last post, I'd finished creating the first part of the new photo gallery, but I wanted to change the dates of the published photos to reflect the ones on the client's original website.
Firstly, I'll refer to the previous list of published galleries that I created before, and create something different that also displays the created and modified dates. Picking the node ID of the required gallery, I used the following SQL query to display a list of photos.
SELECT n.title, n.nid, n.created, n.changed, p.field_gallery_nid FROM node n, content_type_photo pWHERE n.type = 'photo' AND p.field_gallery_nid = 103AND n.nid = p.nid ORDER BY n.nid ASC;
When I look back at the old photo gallery, I can see that the previous 'last added' date was June 27, 2008. So, how do I update my new photos to reflect that date? Using http://www.onlineconversion.com/unix_time.htm, I can enter the required date in its readable format, and it will give me the equivilent UNIX timestamp. To keep things relatively simple, I'll set all photos within this gallery to the same time.
The result that I'm given is '1217149200'. I can now use an UPDATE statement within another SQL query to update the created and modified dates.
UPDATE node INNER JOIN content_type_photo ON node.nid = content_type_photo.nid SET node.created = 1217149200, node.changed = 1217149200 WHERE content_type_photo.field_gallery_nid = 103
Now when I query the database, both the created and modified databases have been updated, and when I return to the new photo gallery, the updated value is being displayed.
Once the changes have been applied, it's a case of repeating the above process for each of the required galleries.
In the next post, I'll explain how to add a count of published galleries and photos on the main photo gallery page, as well as how to install and configure the Shadowbox module.
About the Author
Oliver Davies is a full-stack Web Developer and System Administrator based in the UK. He is a Senior Developer at Microserve and a part-time freelancer specialising in Drupal, Symfony and Laravel development and Linux systems administration.