Embed an image in a story node (or other node)

etamar - March 12, 2008 - 04:26
Project:Gallerix
Version:5.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:postponed
Description

Some imaging galleries allow you to embed a picture within story nodes. For example, we could use a notation of [gallerix:5#15] to get image 15 out of gallery number five. How difficult would this be to accomplish using Gallerix?

#1

silviogutierrez - March 12, 2008 - 17:43

I like this suggestion a lot. I've been teaching myself how to write filters lately, so it shouldn't be a problem. I'll put this near the top of my to-do pile for v1.3.

Silvio

#2

etamar - July 10, 2008 - 10:46

Thanks Silvio, can't wait to see it coming up!

All the best,
Etamar

#3

silviogutierrez - July 18, 2008 - 00:30
Status:active» postponed

I really do like the sound of this feature, but I've got some more critical features to add. I hope to put it into v1.4.

Silvio

#4

eoneillPPH - September 19, 2008 - 20:19

We've done something similar, though a bit more involved... I aded a CCK node-reference field to the "Album" content type. I called it "Story Link" (field_story_link_nid) and made it an auto-complete with default value of the following php code:

if (is_numeric(arg(3))) {
  return array(0 => array('nid' => arg(3)));
}
else {
  return array(0 => array('nid'));
}

and set it as allowed to reference nodes of type NOT including "Album" (that may be moot, for our situation of setting a default value -- also see next code bit).

Then, on our node template, I added this:

  <?php if($node->type!='album' && is_numeric(arg(1))): ?>
<div class="gallerix-link">
<a href="/node/add/album/<?=$node->nid?>">Click here to add a photo album to this story</a>
</div>
  <?php endif; ?>

So clicking this link results in a gallery referenced to the story node it was created from. THEN!! I added a new block type in the gallerix module that I called "associated pictures", enabled it for the content area of my choice (right sidebar) and configured it to only show up if there is an arg(1) and it is numeric:
<?php
 
if (is_numeric(arg(1)) {
   
$node = node_load(arg(1));
    if (
$node->type != "album") return true;
    else return
false;
}
else return
false;
?>

Edit: Or, if you're using Clean URL's, set it to be visible for all pages except album/* and any other types you wish to exclude (I believe this might save a db hit)./Edit

The block is just a copy of the blocks Silvio already defined, with this change to the sql statement:

  $sql = db_rewrite_sql("SELECT g.pid FROM {gallerix_pictures} g INNER JOIN {content_type_album} n ON g.nid = n.nid WHERE n.field_story_link_nid = %d GROUP BY g.pid ORDER BY added DESC");

Not yet running "live," but it's working on our development box. Perhaps it'll help somebody else out there...

 
 

Drupal is a registered trademark of Dries Buytaert.