Download & Extend

Only show CCK:Blocks, if field has content

Project:CCK Blocks
Version:6.x-1.3
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs work

Issue Summary

I installed CCK Blocks and it works great,
but it also shows me the blocks at node view (or that is to say: the title of the blocks), if the user did not enter any content into the particular cck field.

Is it possible to only show the blocks, if they have to present content?

Comments

#1

No idea?

#2

I tried to limit the visibility only to the nodes where I used the ckk fields -> the CCK:Blocks show the title at any time
I tried to set the visibilty to everywhere -> the CCK:Blocks show the title at any time

But: there is one cck field, that only get's displayed, when there is data filled in. But it has the very same settings as the other fields too. And oddly enough the title appears sometimes, when there is no content, but disappears later again. I tried to clear cache but I can't see any regularity.

#3

bump, still got this problem.

#4

Category:support request» bug report

#5

Do you still have this problem? I'm using CCK blocks with empty fields in some nodes and the block is not displayed there.

#6

Can't tell at the moment, because I stopped using this module because of the issue CCK Block shows everything in one line

#7

Status:active» closed (works as designed)

That issue will be fixed in the next -dev release. I close this issue. Please re-open it or create a new one, if you have the problem again. Please provide information about the field type, you have this problem with. This is important, as we do only display the content, that is provided by the corresponding module. We ask the module, providing your field, to format its content and display it in the block.

If the module gives us more than an empty string, even if the field is empty, the block is visible (or at least it's title).

#8

Status:closed (works as designed)» active

I experience the same behavior when using ImageField. If there is no file/image uploaded into the CCK field, I expect that the block would not appear at all. However, it does, with no content.

#9

Status:active» closed (works as designed)

My mistake! In my case, the FileField could not find the image on my system, so the view was actually rendered as an HTML comment:

<!-- File not found: sites/default/files/banner.jpg -->

Now that I have that resolved, the block does not appear.

#10

Status:closed (works as designed)» needs review

I also encountered this problem.
- I have a node type called news with a non-mandatory cck text field called key facts. For this field I created a block.
- I create a news node while leaving the field key facts empty.
- When viewing the node, I expect the key facts block to disappear (as there's no data to display). But instead the block is still shown, with its title and no content.

I use cck blocks 6.x-1.3. The attached fix resolved the problem.

AttachmentSize
cck_module_6.x-1.3-no-content.patch 2.09 KB

#11

Version:6.x-1.1» 6.x-1.3

Are you using a wysiwyg editor? I'll add the patch to the next -dev. Please check, if it still works as expected.

#12

Status:needs review» reviewed & tested by the community

I just tested this patch against 1.3 and it worked perfectly.

Attached is a "revised" patch which was done using diff, rather than "git diff". It also tidies up a few stray empty spaces; no functional changes.

I think this is RTBC.

AttachmentSize
cck_blocks.no-content.patch 1.74 KB

#13

Status:reviewed & tested by the community» needs work

I just tested this, and found that it works correctly if I have only one block on a content type.

However, if I have two then they both appear even if only one of the blocks contains content.

I set this issue back to "needs work" - I hope that was appropriate.

Thank you so much for this sooo coool module!

#14

@Colorado - when you say "two blocks", do you mean two different fields exposed as blocks? What field type are they?

#15

I had a similar problem, where the CCK_block was the only thing in my right-sidebar. But the right-sidebar did not collapse when the CCK_Block should have been empty.

THANKS FOR THE PATCH. But the test in the patch didn't work for me
+ $block_content = drupal_render($cck_field_data);
+ if (trim($block_content) != '') {
because the $block_content contains a bunch of 'span id="thmr_42" class="thmr_call" ' that get inserted by Devel module.

Had to use a really ugly test, by checking the values in cck_field_data of the first CCK_block fields, with a
+ if (trim($cck_field_data['field']['items'][0]['#item']['value']) != '') {

#16

Same issue here.
I'm using Context to place the block, in case that's a piece of it.

#17

Little more weirdness...

When the field was added to the content type after the time it was last saved (and the field value is NULL) CCK doesn't seem to know what to do and DOES NOT show the block. Saving it causes the block to show when it still should not.

I'm using this on a on/off checkbox to show a badge. Node saved with checkbox unset do not show the CCK block, nodes with checked show the CCK block, old nodes never saved after it was created still show the block though the value is unknown. Perhaps their's an issue with on/off value still being a value?

nobody click here