When displaying Bean blocks in a view (using the block field 'Rendered Block') the Bean title field is never displayed. I know that the Bean title can be added as another field but this kind of defeats the usefulness of using entity view modes (and sadly doesn't quite fit my intended use case for a current project).

I had hoped that http://drupal.org/node/1836798 might have fixed the issue but sadly that was just wishful thinking.

Is this an easy fix?

Files: 
CommentFileSizeAuthor
#12 bean-display_the_title-1858416-12.patch552 bytesgabriel.achille
PASSED: [[SimpleTest]]: [MySQL] 98 pass(es).
[ View ]
#8 bean-display_the_title-1858416-8.patch573 bytesdanielgmc
FAILED: [[SimpleTest]]: [MySQL] Invalid patch format in bean-display_the_title-1858416-8.patch.
[ View ]

Comments

This happens via EntityReference displays too (#1891210: Incompatible with entity reference formatter "Rendered Entity"), only the contents of the bean are displayed, the title is not.

Title:Views field 'Rendered Block' does not display the Bean titleRendered bean does not display the title when display settings indicate it should

Going through the logic..

The module allows you to control whether the title is displayed per view mode from admin/structure/block-types/manage/[beantype]/display, so therefore the title, like all fields, should adhere to the display settings for that view mode.

I see where you are going @DamienMcKenna, BTW, thanks and awesome work today!

The problem is the integration with the block module. Since the title is rendered separately, we would need to default to the title being hidden in the default display mode. This would integrate with "core" theming and such. Then a site that uses only beans could react to the bean differently? How does that sound?

Shouldn't it be ok to just adhere to the bean's view mode display settings? I was digging around, might there be a way to change the title field's default formatter in bean_field_extra_fields() to 'hidden'?

Contextual links would also be awesome... oh wait, those are rendered with title-suffix aren't they? /d'oh!/

Bean implements hook_field_extra_fields for title so it acts as if you can configure it in manage displays.

For that functionality to work though, the field needs to be part of $entity->content which 'title' is not.

put this in bean.module

function bean_entity_view($entity, $type, $view_mode, $langcode) {
  if ($type == 'bean') {
    $entity->content['title']['#markup'] = $entity->title;
  }
}

@yechuah Should we make a patch of this for inclusion in Bean?

Issue summary:View changes
StatusFileSize
new573 bytes
FAILED: [[SimpleTest]]: [MySQL] Invalid patch format in bean-display_the_title-1858416-8.patch.
[ View ]

I've used some of this code in one of my projects, so thanks!

Attaching a patch. The bean title will display as H2.

Status:Active» Needs review

set as "need review" for automatic test.

Status:Needs review» Needs work

The last submitted patch, 8: bean-display_the_title-1858416-8.patch, failed testing.

The last submitted patch, 8: bean-display_the_title-1858416-8.patch, failed testing.

Status:Needs work» Needs review
StatusFileSize
new552 bytes
PASSED: [[SimpleTest]]: [MySQL] 98 pass(es).
[ View ]

hmm... i just removed some Windows line endings and convert tab into spaces.
Let's try again.

Status:Needs review» Reviewed & tested by the community

Tested locally and confirmed functionality.

hmm so for me this leads to duplicate block titles - one properly placed via entity display, and in the conventional block title position. this is with only bean and bean_admin_ui enabled, mind you

Status:Reviewed & tested by the community» Needs work

Setting to needs work per comment #14.

  1. +++ b/bean.module
    @@ -772,6 +772,19 @@ function bean_create($values) {
    + * Implements hook_entity_view()

    Have we tried doing this in bean_view rather than hook_entity_view? IMO this is not the proper use of that hook.

  2. +++ b/bean.module
    @@ -772,6 +772,19 @@ function bean_create($values) {
    +      '#tag' => 'h2',

    I'm not a fan of hard coding elements outside of a theme function.

I think this same issue came up with fieldable panel panes as well - the duplicate entity title vs render title issue, specifically. The workaround as I recall was to have the pane at the preprocessing step look to see if the title was set in the entity, and then hide it's own title if the entity had a title set. I agree about #2, would prefer that the element not be hardcoded. Possibly a theme function should be written to handle it, similar to block title?

*comment removed*