Hi,
Today I created a custom layout - yay!

It did not work in the first place. In all but one region, fields were always printed as "<", instead of the field content. So that region with two fields would print as "<<". Weird..

Then I found this was all caused by the main region being called "content". Renaming it to something else, like "ccontent" or "middle", did fix it. It did cost me some time to figure this out.

I wonder, what can be done about this. Either to support arbitrary field names, or to show a warning.
Ideas?

CommentFileSizeAuthor
#7 1382132-ds-message-isset.patch972 bytesandypost
#4 1382132-1.patch813 bytesswentel
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

swentel’s picture

Yeah, 'content' is indeed a forbidden region name. I've been thinking about how to warn people about this. I think 3 things meed to be done:

1: use hook_requirements()
2: do not list a layout with a 'content' region in the selection box
3: warn about this in documentation and also in the drush ds-build

donquixote’s picture

The more often and the more visibly it explodes, the better :)
A drupal_set_message() would not hurt.

Just mysteriously not listing the layout sounds not a good idea. Unless you show a warning alongside.
hook_requirements(), don't know yet, but yeah, if it works, sure!

Btw, is 'content' the only reserved name?

swentel’s picture

yeah, content is the only one that is reserved - at least, the only one I know of, but I'm pretty sure it's the only one. Adding a drupal_set_message() is probably a good idea and will warn much faster than hook_requirements, people tend to miss that.

swentel’s picture

Status: Active » Fixed
FileSize
813 bytes

Patch attached, committed and pushed.

donquixote’s picture

Thanks!
One of the " is a bit misplaced, though.

swentel’s picture

Aarg, stupid double quote :) Fixed :)

andypost’s picture

Status: Fixed » Needs review
FileSize
972 bytes

Last commit also changed message in ds.field_ui.inc

Suppose better use isset() then array_key_exists()

swentel’s picture

Status: Needs review » Fixed

Ah crap, was testing another patch, forgot to revert that one. isset() is also a bit faster, so makes sense. Thanks, committed and pushed!

Status: Fixed » Closed (fixed)

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

HnLn’s picture

This causes error messages for panel layouts with a 'content' region: see http://drupal.org/node/1382132. Not sure if this issue should be reopenend or if the issue will be followed up in the new one. (also don't know why 'content' region is forbidden).

andypost’s picture

Status: Closed (fixed) » Needs work

this require more descriptive explanation about why "content" is not allow name for region

Panels could use any name for it's regions

EDIT ref #1382132: hook_ds_layout_info(): Some region names are forbidden.

swentel’s picture

Status: Needs work » Closed (fixed)

Because when entities are rendered, the field items are stored into a 'content' key (except user profile). If a region could have that name, fields would be overwritten before they're all moved. Of course, this doesn't apply to panel layouts at all which why we need to make sure they are ignored ds_get_layout_info(). We'll fix that in the other issue and comments in the code as well so we remember that :)