Attached patch adds the necessary code to turn the title of a bean into a field using title.module so it can then be translatable. Also implements hook_field_extra_fields to display the title field on the fields setting page for each bean type so it can be transformed into a field.

You might also consider adding "label" and "view mode" in hook_field_extra_fields, so they can be then reordered. That's a different issue though.

Comments

duellj’s picture

StatusFileSize
new1.37 KB

Title shouldn't be required, updated patch to reflect that.

indytechcook’s picture

Status: Fixed » Closed (fixed)

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

aroq’s picture

I can't see this part from patch in the last versions of code:

/**
+ * Implements hook_field_extra_fields().
+ */
+function bean_field_extra_fields() {
+ $extra = array();
+
+ foreach (bean_get_types() as $type) {
+ $extra['bean'][$type->type] = array(
+ 'form' => array(
+ 'title' => array(
+ 'label' => t('Title'),
+ 'description' => t('Bean module element'),
+ 'weight' => -5,
+ ),
+ ),
+ );
+ }
+
+ return $extra;
+}
+
+/**
is it needed to make title module support working?

davemybes’s picture

Yep, that missing bit of code is needed to get the Title field to appear and have Title module replace it.

Hmm, I get the following error when replacing the title:

An AJAX HTTP error occurred. HTTP Result Code: 500 Debugging information follows. Path: /batch?id=295928&op=do StatusText: Service unavailable (with message) ResponseText: EntityMetadataWrapperException: Unknown data property title_field. in EntityStructureWrapper->getPropertyInfo() (line 339 of .../sites/all/modules/contrib/entity/includes/entity.wrapper.inc).

The field appears to get replaced, but throws out a "The website encountered an unexpected error. Please try again later." error when you try to translate the block. I get the same error if I edit the new Title field and try to save it. You can delete the field and the site returns to normal.

*edit* Update title module to latest version fixes the problem. So using the following versions now:
Bean 7.x-1.0-rc5 (added missing code mentioned above)
Entity_translation 7.x-1.0-alpha2
Title 7.x-1.0-alpha3

james.williams’s picture

Status: Closed (fixed) » Needs review
StatusFileSize
new387 bytes

Unfortunately, things have changed since this patch, and I now find I get a 'Maximum function nesting level' (recursion) error when using the title field with the bean module. The attached patch solves this, as the defined label callback is no longer needed, and the default behaviour still seems to be correct. Explicitly defining the label callback results in the recursion error.

indytechcook’s picture

Status: Needs review » Needs work

Thanks James, that patch will not be applied as it removes all of the logic for the title out of the class. There is currently logic in there to change the label depending on where the bean is being displayed.

james.williams’s picture

Ah, I had missed that the Bean class has a defined defaultLabel() method that does this, sorry. The issue does indeed need work then... I hope to get this issue solved before too long, but of course anyone is welcome to beat me to it!

Dishna’s picture

Issue summary: View changes

I am working on a multilingual site and have a issue with bean block not translating title. Is there a solution for this issue?
Help would be really appreciated.

timfernihough’s picture

StatusFileSize
new820 bytes
new820 bytes

It turns out a customer of ours, for a site we have inherited, has used @james.williams patch from #6. Due to security updates, I have had to re-roll this patch for 7.x-1.11. I'm posting it here in case anyone else ever needs it but I don't expect this to be included. It is simply for those who might have relied on that patch for something and are now facing the prospect of security updates wiping this out.