I would like to use the teaser display when showing all my galleries, with a row of photos from that gallery. However, when a user clicks on a photo, I don't want them taken to the image node (as currently happens). I would like them to be taken to the gallery node page, displaying the selected image. In addition I am using Views Galleriffic to display images on the gallery node, so it would need to work with this as well.

Not sure if this is an image_cache or a Node Gallery issue? When selecting how the image is displayed in the view, they all look like image cache options (image linked to node, url, image, etc.), but perhaps those options are supplied by other modules?

As a workaround, I am wondering if it would be achieved with something like Global Redirect, sending requests for image nodes to their respective gallery node. But I don't know if I could a) find out the gallery nid in Global Redirect and b) work out the appropriate anchor fragment to make galleriffic show the correct photo?

Comments

scroogie’s picture

> When selecting how the image is displayed in the view, they all look like image cache options (image linked to
> node, url, image, etc.), but perhaps those options are supplied by other modules?

Are you talking about the options on an image field here? If so, these are indeed "Imagecache formatters" that determine how the image is displayed. Imagecache offers a hook to define these in other modules, so the answer to the second question is yes. Node Gallery also offers some formatters, such as "Node Gallery Image linked to Gallery", which should be the one you are searching.

hth

nasi’s picture

Ahh, I hadn't spotted those extra formatters; they were buried beneath a gazillion Lightbox2 formatters…

The "node-gallery-thumbnail image linked to gallery" gets me half way there, in that it takes me to the gallery rather than the node. But it always goes to the first image in the gallery and not to the image clicked on within the gallery. So what would be great would be a modified/added formatter that could add the necessary url fragment so that galleriffic goes straight to the correct image.

e.g. When I click on the fourth thumbnail in the teaser, I get taken to node/1234#4 instead of just node/1234

Is that possible?

scroogie’s picture

Not with the current code. This would require numbering all items of the view with anchors, probably through views templates. I doubt that it's feasible for core, but I'll wait for additional comments.

nasi’s picture

Would it require additional numbering of the images? The number/position of each image is already inherently stored in the sort order, so possibly:

a) a formatter could be modified to provide the anchor derived from sort order?
or
b) this could somehow be done with views when it is iterating through the rows?

scroogie’s picture

a) is not possible, because the formatter does not know of any other images that are displayed near or next to it. It only knows its own image.

b) is possible. Thats what I meant in my post. It would need overriding the views template.

nasi’s picture

I'll have a look into b) then. Any pointer on how to get going?

scroogie’s picture

Have a look at the view under themeing, it shows you the possible template overrides that you can use. Copy the original file from the Views theme folder and print_r() the available variables to get an overview.

justintime’s picture

Category: feature » support

Moving this to a support request for the time being.

nasi’s picture

Ok, so I'm trying to write a theme override for the views field output, and I have created a tpl file in my theme's folder: views-view-field--node-gallery-gallery-image-views--attachment-2--field-node-gallery-image-fid.tpl.php. But, the default tpl provided by views is rather basic, containing the single line:

print $output;

What I'm struggling to find is the code that creates $output in the first place, so I can copy and amend it for my needs? Is this something that happens with in the NG code and if so, where?

scroogie’s picture

This is a bit more complex. It depends on which displays you use for the teaser display and the full page display. Lets assume that you use the "View images teaser" for teasers and "View all image thumbnails" for full page.
In that case you have to create two templates in your theme folder:

views-view-fields--node-gallery-gallery-image-views--page-1.tpl
and
views-view-fields--node-gallery-gallery-image-views--page-2.tpl

The first is for the full page view and the second is for the teaser. Now in your Views UI you set the formatter for the image field on the second view to an imagecache formatter that *does not* contain a link. So just set it to "node-gallery-thumbnail image".

Now in the Views templates, you need to create the anchors in the first and the links in the second. Here is example code:

views-view-fields--node-gallery-gallery-image-views--page-1.tpl:

<a name="node-<?php print $row->nid; ?>">
<?php foreach ($fields as $id => $field): ?>
  <?php if (!empty($field->separator)): ?>
    <?php print $field->separator; ?>
  <?php endif; ?>

  <<?php print $field->inline_html;?> class="views-field-<?php print $field->class; ?>">
    <?php if ($field->label): ?>
      <label class="views-label-<?php print $field->class; ?>">
        <?php print $field->label; ?>:
      </label>
    <?php endif; ?>
      <?php
      // $field->element_type is either SPAN or DIV depending upon whether or not
      // the field is a 'block' element type or 'inline' element type.
      ?>
      <<?php print $field->element_type; ?> class="field-content"><?php print $field->content; ?></<?php print $field->element_type; ?>>
  </<?php print $field->inline_html;?>>
<?php endforeach; ?>
</a>

views-view-fields--node-gallery-gallery-image-views--page-2.tpl:

<?php foreach ($fields as $id => $field): ?>
  <?php if (!empty($field->separator)): ?>
    <?php print $field->separator; ?>
  <?php endif; ?>

  <<?php print $field->inline_html;?> class="views-field-<?php print $field->class; ?>">
    <?php if ($field->label): ?>
      <label class="views-label-<?php print $field->class; ?>">
        <?php print $field->label; ?>:
      </label>
    <?php endif; ?>
      <?php
      // $field->element_type is either SPAN or DIV depending upon whether or not
      // the field is a 'block' element type or 'inline' element type.
      ?>
      <<?php print $field->element_type; ?> class="field-content"><a href="<?php print url('node/'.$view->args[0]) . '#node-' . $row->nid; ?>"><?php print $field->content; ?></a></<?php print $field->element_type; ?>>
  </<?php print $field->inline_html;?>>
<?php endforeach; ?>
nasi’s picture

Thanks for the code; things are starting to make a lot more sense to me now. :)

The problem that still remains, for me, is that I am trying to integrate with the Views Galleriffic module – my full page view has a 'Galleriffic Gallery' style and 'Galleriffic Fields' row style. I am also using the History option, which appends # to the url for each image.

The difficulty is that the anchor tags used are not the node nids, they are just numbers, from 0 upwards, and they are inserted into the html by JS on page load.

There are a couple of issues with this:

1. It seems that the row style output is themed before the style output is themed, so I'm not sure if it is possible to pass a counter into the row theme code at all.

2. Even if I can do 1. then it will break in cases where Javascript is disabled, as galleriffic does not degrade sufficiently gracefully for those anchor tags to have any meaning, if they anchors haven't been rewritten on page load.

I might have to go back to square one with this… :(

scroogie’s picture

I'd actually suggest to fix this in Javascript code then. It's much easier to do there.

zengenuity’s picture

Status: Active » Closed (won't fix)

At this point, I won't be adding new features to the D6 version. If features are wanted for D7, please post a new issue.