This repository has been archived on 2025-01-19. You can view files and clone it, but cannot push or open issues or pull requests.
oliverdavies.uk-old-sculpin/source/_posts/create-better-photo-gallery-drupal-part-2.md
Oliver Davies 85a10c545b Run prettier on all *.md files
```
prettier '{app,source}/**/**.md' --write
```
2020-03-08 17:57:45 +00:00

59 lines
2.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: Create a Better Photo Gallery in Drupal - Part 2
date: 2010-08-17
excerpt: Updating the galleries created and modified dates.
tags:
- drupal-planet
- drupal-6
- photo-gallery
- sql
- sequel-pro
---
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.
```language-sql
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.
```language-sql
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 dates 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](http://drupal.org/project/shadowbox) module.