About a month ago there was a task for me to create images gallery with photos mass upload in Drupal. I know, there is Image module and a lot of others modules that can do it, but the task was unusual - gallery should be node and image in this gallery should be node too. Study drupal.org yielded nothing, nor desired module, nor tutorial. So i decided to make something by myself.
What you'll need:
1. Image module
2. Image Import module
3. Viewfield module (requires Content and Views, as you can see from the module name and small modification)
4. Hands :)
So the steps you required to do to organize gallery:
1. Create content type for gallery. Call it as you wish, "Gallery" is all right.
2. Add viewfield to this content type
3. Create taxonomy vocabulary and associate it with both of the node types: Image and Gallery. Every gallery will have it's own taxonomy term and images in this gallery will have the same. This is required for view to understand what images connected with what gallery.
4. Create view with argument: "Taxonomy Term" and filter "Node Type: Image". You can also change some other settings, it is optional.
And the steps you when creating a gallery:
1. Upload images to the folder you are created (default is: 'files/images/import')
2. Create a new term in the vocabulary for the new gallery
3. Go to admin/content/image_import and upload images to nodes. Do not forget to select the term you created in p.2, so all images will have the same term.
4. Create new Gallery (content type). In the viewfield select the view you created in p.4 beforeand in the view argument place %tid. This is the modification we need to add to viewfield.module at line 104:
foreach ($node->taxonomy as $key => $value) {
if ($value->vid == 8) { // 8 is the vid of vocabulary you created when organizing gallery
$tid = $value->tid;
}
}
$translated_args = strtr($a, array('%nid' => $node->nid, '%author' => $node->uid, '%viewer' => $user->uid, <b>'%tid' => $tid</b>));And that's it. Of course both of the content types needs to be themed, and there are a lot of steps we should pass to create a gallery. This problems will be in the next part of this post. Stay tuned!




Post new comment