Hi!

Have you ever thought about integrating the Token module?

Imagine the following:
1. create a node (eg. page)
2. upload images as attachment (via upload module)
3. save them into a well formed folder structure via the upload path module (eg. pages/nid-34/images/)
4. display them within a dynamic display block by setting the block's input folder to pages/nid-[nid]/images/

In the end you have an image (or video) gallery that is assosiated with a certain node and that is being managed at a single place: the node's edit page

Comments

ppblaauw’s picture

Status: Active » Needs review

Thank you for this writeup, and no, did not think of your scenario to get images from a folder this way.

As I understand nothing has to be done in the ddblock module.
Only write a more detailed tutorial how to do it.

Edit:

A more detailed howto can be found at: How to create a basic dynamic display block image slideshow with images from a folder created as node attachments on http://ddblock.myalbums.biz

der_tisch’s picture

I have just read your howto. Have you tried that out by yourself and it worked?

As far as I understand the Token module it is an API that has to be explicitly used by other modules. It does not work for a module just by installing it.

I assume in the case of ddblock something like

      if (module_exists('token') && function_exists('token_replace')) {
          $imagepath = token_replace($imagepath, 'node', $current_node);
      }

has to be added in line 1537 of ddblock.module.

I am not sure about the use of the second and third argument.
And I do not know where to get the $current_node variable from. Unfortunately I am not yet familiar with the core drupal API.

ppblaauw’s picture

Yes, I made the tutorial while trying your suggestions. It works perfectly.

The token module works in this case together with the upload path module.
The path where images are stored uses the token. In this case the [nid] token.
So nothing to change in the dynamic display block module if you use the upload path module!

So if you set the path ddblock/nid-[nid]/images into the upload path module for the content type you use for your image gallery, the images you upload for e.g node 10 of this content type will be stored in ddblock/nid-10/images

When you make a ddblock block you can use ddblock/nid-10/images as your image folder.

Works perfect. The only thing you have to do is attach at least 2 images to node 10.

der_tisch’s picture

Now I understand. Maybe I have made my idea not clear enough.

When I proposed to enter "pages/nid-[nid]/images/" into ddblock's input folder settings I did not mean to manually replace [nid] by the node id that was remembered before but to enter this string as it is.
In ddblock.module you then use the Token module (in the case it is present) to replace this nid-token (ore any other token) with values from the currently displayed node. I think this should be done just before _ddblock_get_image_array(...) is called.

That should lead to an image galleries that are automatically associated to nodes of that specific node type.
This gallery has to be set up only one time.
Afterwards you just have to attach images to a node and these images are automatically displayed in ddblock.

ppblaauw’s picture

Ok, now I understand your proposal!
To use "pages/nid-[nid]/images/" into ddblock's input folder settings and use the token also here.

In your proposal the difference is you don't have to remember the node you want to make a ddblock gallery but the remaining functionality is the same:

  • This gallery has to be set up only one time. (create ddblock for a node).
  • Afterwards you just have to attach images to a node and these images are automatically displayed in ddblock.

The ddblock does not know which node is used (It get's the images from the folder you set in the ddblock configuration page for the folder setting. That the images in this folder are placed by the path upload module for a certain node it does not know).

So, you never can get the node_id of the current node, because there is no node, only a folder.

So, I don't have a solution for your proposal.

Maybe I am wrong and there is another solution with the token module, please let me know.

There is a solution to make another input possibility for the ddblock module which doesn't use the imagefolder.

  • Defined in ddblock a content type which has attachments to show in a slideshow.
  • Create a ddblock and select a node of this content type.
  • Display all the attachments of this node in a slideshow.

In this solution you still need to select a node (but this could be a select list (widget) of nodes of the defined content type instead of a node_id)

Any other suggestions welcome.

asak’s picture

I think what der_tisch is asking for is the ability for 1 ddblock to change it's images depending on the node viewed.

This really could be done using views and relationships/arguments, to filter attachments/imagefields/anything to the currently displayed node.

I'm trying to figure out another usecase for token integration... but can't seem to think of any. it would be cool (cause token integration is cool) - but i'm not sure what for... ;)

ppblaauw’s picture

Ok maybe the functionality should be:

  • Enable in the ddblock module content types for showing related images in a slideshow.
  • Enable in the node of this content type if you want to display a slideshow of related images.
  • If enabled, select one or more of the following: all images, attached images, images in image fields, etc.
  • If enabled, choose which ddblock you want to display the attachment in.

#asak could you give in more detail how this can be done with views.

Some weeks ago there was another issue Errors when view contains no items Where the poster of the issue set up a view to show images related to the current node. The node contains a nodereference field pointing to nodes containing the images (stored as CCK imagefields). The view is set to take the current node ID as an argument.

Also this could be a possibility.

Any other suggestions welcome