https://cgit.drupalcode.org/ds/commit/?id=f539fe122059120fbb6e492bdaa0ec...

ds_render_ctools_field uses $block->content['#markup'] to get the rendered content of the block, but that's not always set. _block_render_blocks() sets it if the block function returned a string for the content, but if the block function returns a render array, there's no guarantee that there's a '#markup' key.

The correct way to ensure that the content is a string is drupal_render($block->content);

Comments

Xen created an issue. See original summary.

t14’s picture

StatusFileSize
new456 bytes

This was causing issues for me.
The recommended fix suggested by Xen works.
I have attached a patch based on Xen suggested use of drupal_render()

fizzbin’s picture

Above fixes our issue as well (blank main-nav populated by block). Recommend t14's patch to be merged ASAP!

k_a_l’s picture

StatusFileSize
new1.18 KB

I'm wondering if we should implement the same for the "Show block content + title" option as well.

xen’s picture

isset($block->content) isn't quite enough to determine if there's any content. An empty array would be considered content. block.module itself uses isset($block->content) && $block->content.

@k_a_l, yes it should.

k_a_l’s picture

StatusFileSize
new961 bytes

I've added an additional check for an empty block content array.

k_a_l’s picture

Status: Active » Needs review

Updating to "needs review"

shubhraprakash’s picture

Well you can use !empty($block->content) to check for both conditions at one go. I have used it in this patch and it works fine.

artfulrobot’s picture

This caused a major issue for me, but patch in #6 works for me. Thanks.

k_a_l’s picture

Status: Needs review » Reviewed & tested by the community

This seems to be causing a lot of issues for people, including myself, so I'm saying this looks ready to be committed.

dhansen’s picture

This breaks all block-base fields with Menus in them. +1 for RTBC.

armrus’s picture

+1 RTBC

jimmynash’s picture

This patch fixed my issue with rendering some DS block fields.

Thanks!

rivimey’s picture

+1 for me.

Any idea when this will get into a stable release?

owenbush’s picture

This patch worked for me too.

rivimey’s picture

  • aspilicious committed 41e8caf on 7.x-2.x authored by k_a_l
    Issue #2962309 by k_a_l, t14: Don't use $block->content['#markup']
    
aspilicious’s picture

Status: Reviewed & tested by the community » Fixed

Fixed and tagged a new release.
Sorry for the delay!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.