By eberian on
Hi All,
Is there a way (module or custom php perhaps?) to attach an image to a node, but to display the image in a block, instead of in the body of the node itself?
Essentially I'm thinking about techniques for creating a side block that is tied to a specific node, without the overhead of creating a block separately and then having to fix the page it displays on.
I'm using Drupal6 and the Image module. All suggestions gratefully received.
Thanks and best regards,
Ed
Comments
Strangely enough, it's
Strangely enough, it's called "image_attach". Can't imagine what they were thinking when they came up with that obscure name.
Even stranger, you already have it installed. Try enabling it.
I found that it tended to enable its block automatically, and had to always remember to make it STOP doing the behavior you are asking for.
.dan.
How to troubleshoot Drupal | http://www.coders.co.nz/
.dan. is the New Zealand Drupal Developer working on Government Web Standards
Ooops - I saw Image_attach,
Ooops - I saw Image_attach, but must have misinterpreted what it does - I thought it was for attaching images inline in a node - not in the side bar.
Is there a similar solution for tying other content blobs to a node and displaying them in the side block?
Thanks, I will give it a go.
I think it's called
I think it's called content_block. or block_content. maybe even node_block. But it's out there.
Or you can hand-roll a version, but go looking.
.dan.
How to troubleshoot Drupal | http://www.coders.co.nz/
.dan. is the New Zealand Drupal Developer working on Government Web Standards
image_attach missing 'region' value in block table?
Ok, I went back to a separate year-old Drupal5 installation and updated the Image module to the latest version in order to get this block logic that was added last september ( http://drupal.org/node/113326 ). That gave me the "Attached Images" block on the admin/build/block page - just as you described.
The block was missing in my Drupal6 installation though.
I started looking through the drupal5 and drupal6 code and databases. Unlike the drupal5 db, on the drupal6 db, the block.region field was blank for image_assist, so I put 'left' in. When I refreshed the block admin page, the "Attached Images" block suddenly appeared.
That was the first and only change I made to the database. I've just run a completely fresh install of Drupal6.2 and Image 6.x-1.0-alpha1, and they have exactly the same problem. I've also done of diff of Image 6.x-1.0-alpha1 and the 6.x-1.x-dev snapshot from 2008-Jun-11 ~ doesn't look like there are any significant changes to the code that would fix it.
Edited 'image_attach.module' to add:
'region' => 'left',at line 68, and ran a fresh install. That fixed it. Don't understand why though, because other blocks seems to manage without a region value.
Any suggestions?
I'm unhappy with the way it
I'm unhappy with the way it auto-enables its block all the time on install anyway. That hook_block() call is a bit inappropriate the way it declares itself always-on.
Normal Drupal-ness is : enable module, go find block, enable and position block.
I imagine that you could have just enabled the block in block admin still? or maybe something changed a bit in D6 and it was objecting to the preset values. And how tou you plan on disabling or moving the block in the UI?
I say those hook_block(list) values should not be there. I suspect they also cause the block to magically re-appear sometimes after I was sure I turned it off. They certainly pop up again any time I switch theme.
.dan.
How to troubleshoot Drupal | http://www.coders.co.nz/
.dan. is the New Zealand Drupal Developer working on Government Web Standards
I'm pretty much a newbie to
I'm pretty much a newbie to drupal internals, but from what you say it sounds like a bug/violation of best practices.
In Drupal6, without setting a region value, the block just didn't appear at all - it wasn't that in was in the display: section - it was totally absent. Once set, I can move the block around, set it to , all without problems. Weird.
When I have a spare moment, I will look into image_attach_block() and see about submitting a patch. At the moment, it sets
'status'=>TRUE,which seems (from my copy of 'Pro Drupal Development') to be what's giving you grief (In drupal5?)Don't suppose you can recommend a particularly well-behaved Drupal6 module that I can use as a reference design?
Thanks for all your help,
Ed
yeah.
grief? well, I said inappropriate.
Simply omitting that parameter seems to be the best-behavior I'd expect.
Granted, I like modules getting in-your-face about the functionality they provide, this one is ... too much.
Not a biggie. But could be dropped.
.dan.
How to troubleshoot Drupal | http://www.coders.co.nz/
.dan. is the New Zealand Drupal Developer working on Government Web Standards
eberian, thanks very much for
eberian, thanks very much for the workaround. As I'm using this block now, I posted an issue on the problem:
http://drupal.org/node/426724#comment-1449046
If you get back to working on this: I wonder if the "visibility" field might have some bearing.