Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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?
Comment | File | Size | Author |
---|---|---|---|
#7 | 1382132-ds-message-isset.patch | 972 bytes | andypost |
#4 | 1382132-1.patch | 813 bytes | swentel |
Comments
Comment #1
swentel CreditAttribution: swentel commentedYeah, '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
Comment #2
donquixote CreditAttribution: donquixote commentedThe 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?
Comment #3
swentel CreditAttribution: swentel commentedyeah, 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.
Comment #4
swentel CreditAttribution: swentel commentedPatch attached, committed and pushed.
Comment #5
donquixote CreditAttribution: donquixote commentedThanks!
One of the " is a bit misplaced, though.
Comment #6
swentel CreditAttribution: swentel commentedAarg, stupid double quote :) Fixed :)
Comment #7
andypostLast commit also changed message in ds.field_ui.inc
Suppose better use isset() then array_key_exists()
Comment #8
swentel CreditAttribution: swentel commentedAh crap, was testing another patch, forgot to revert that one. isset() is also a bit faster, so makes sense. Thanks, committed and pushed!
Comment #10
HnLn CreditAttribution: HnLn commentedThis 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).
Comment #11
andypostthis 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.
Comment #12
swentel CreditAttribution: swentel commentedBecause 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 :)