Insert Blocks in CCK text fields not working

hobbes_VT - January 12, 2009 - 00:17
Project:Insert Block
Version:5.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs work
Description

Hi mlsamuelson - first of all, this is a great module - although apparently hardly any updates have been done on version 5.x.

Anyway, this is my first attempt to actively contribute to a module as I've fixed an issue for my own purpose and wanted to share this with others who might need the functionality - so please advice if my contributed patch file doesn't meets all the formating requirements - any comments and hints would be highly appreciated if I need to modify the patch to make it applicable for others (I use Eclipse PDT on a windows platform).

So, here's the issue: If you use this module in pages with CCK (text) fields the block tags did not get rendered. This is because you use the insert_block_nodeapi ... maybe you need to do this for some reason I don't know ...

My solution actually uses "process" case of "op" to directly call the substitute function - thus it works for all fields and is not only applied to the content variable (actually the original version just works for body and teaser of the content variable).

Some designers (including me - and that's how I discovered the issue) don't use the content variable in their templates but rather use directly field values (e.g. content['body']['#value']) especially since I have several other CCK fields that need to be printed at different positions in my pages. These values were not updated correctly by the filter ...

I don't know if this is of any help for 6.x - however, I hope this will help someone else, who still works with 5.x versions of modules and has run into a similar issue.

Thanks again for providing this easy to use module - it allows me to do things much simpler and yet with more individual formatting possibilites than panels would do!

Cheers!

AttachmentSize
insert_block 5.x-1.x-dev.module.patch1.59 KB

#1

mlsamuelson - January 14, 2009 - 15:55
Status:needs review» needs work

hobbes_VT,

You correctly diagnose the issue. Originally it was thought that there was no way to disable caching on nodes with inserted blocks - which could be a problem with a dynamic block - thus the use of hook_nodeapi. Since then, we've discovered that if you return TRUE for the 'no cache' $op in hook_filter, you can disable the cache.

The Drupal 6 version of Insert Block dispenses with hook_nodeapi and switches out into a classic filter module method of operation. Because the Drupal 5 version of Insert Block has been humming a long nicely with few issues at this point, I hadn't planned on introducing these changes in that branch. But I'm not against it. I notice your patch doesn't include the 'no cache' $op. If you'd like to create a patch that includes that and keeps the changes close to those in the Drupal-6--1 version I'd happily commit the patch.

The README.txt and insert_block.module files ought to be instructive in considering the changes needed.

Thanks!

mlsamuelson

 
 

Drupal is a registered trademark of Dries Buytaert.