I have setup a page (content type main_page) where I render multiple entities (nodes of content type sub_page) througout Entity reference module. On these node I can choose view mode (basicaly if the image should be on right or left).
But this selection is overriden by manage display (main_page) Rendered entity View mode.

Is there a way how the per node View mode will overide the field View mode?

Comments

cspitzlay’s picture

Category: support » bug

I think this is the same issue that I am facing:
I have two different custom view modes (via ds_extras) on the same page
and only the one from the main page works.

The node whose view is rendered has one configured,
and then there are entities connected via entity_reference
that are supposed to be "rendered as entities" with another custom view mode.

I don't see the rendered referenced entities, whereas if I use a the standard teaser view mode
I can see them.

I think at least part of the problem is the use of a single drupal_static for storing the view mode.
ds_extras_entity_view_alter(&$build, $entity_type) overrides the view mode
using that one single static (drupal_static('ds_extras_view_mode')),
but it would need to use a different one depending on the entity view
being altered at that time, wouldn't it?

Looks like a bug to me, or do I misunderstand the meaning of the view mode setting?

swentel’s picture

Status: Active » Postponed (maintainer needs more info)

That code shouldn't interfere normally as that holds the view mode for the main page, not the entity references, but I can recheck.
Could you give me the exact steps to reproduce, that will be easier for me then.

cspitzlay’s picture

Status: Active » Postponed (maintainer needs more info)

- I used the article content type for the "main" page.
- Each node of that type has a custom view mode created by ds_extras, let's call it viewmode1.
- The article type has a multi-valued entity_reference field that allows you to select entities of a type configured using the entity construction kit, let's call it type2.
- type2 has a custom view mode created by ds_extras, let's call it viewmode2.
- article's viewmode1 is configured to display entities of type2 as "rendered entity" with viewmode2; the field template is set to "Drupal default".

Here are the ds settings:

- Field templates are enabled but set to Drupal default
- Extra fields are disabled
- "View mode per node" is on
- "Page title options" is on
- "Disable Drupal blocks/regions" is off
- "Field permissions" is off
- "Region to block" is on
- "Views displays" is on
- "View mode switcher" is off
- "Hidden region" is off

The block with the rendered entities is configured to appear in "Sidebar second".

Please feel free to contact me if you need additional info.

cspitzlay’s picture

Status: Postponed (maintainer needs more info) » Active
allio_froggio’s picture

Status: Postponed (maintainer needs more info) » Active

I think I'm experiencing something similar. I have an entity reference field that allows the content editor to add images (the referenced entity) to the list (the node). When I don't use a display suite lay out, I can see all the fields: title, the image, the body, etc. But as soon as I use any of the display suite fields, the title is hidden (even when it's enabled). I also cannot see the "read more" link. With my custom fields, I have no issues displayed them using Display Suite. It just seems to be an issue with the core fields that are exposed when I'm using a Display Suite lay out. Any help would be greatly appreciated! (My apologies if this is a completely separate issue.)

kingfisher64’s picture

Having searched the thread with "1 in ds_extras_entity_view_alter()" this returned, so I hope it's appropriate place to report this.

I'm getting the following message on a profile2 profile page using the latest dev versions of profile2 mod, latest 2.6 of ds & a newish mod https://drupal.org/project/issues/fc. Using drupal 7.23.

Error message
Notice: Undefined offset: 1 in ds_extras_entity_view_alter() (line 609 of sites/all/modules/ds/modules/ds_extras/ds_extras.module).

If I can provide anymore information that can be of help, please let me know.

Many thanks.

RobKoberg’s picture

I don't think this is a display suite issue as I am having this problem when I simply define the custom view mode in code, like:

function mash_entity_info_alter(&$entity_info) {
  $entity_info['node']['view modes']['embedded'] = array(
    'label' => t('Embedded'),
    'custom settings' => TRUE,
  );
}

So probably in entityreference somewhere.

aspilicious’s picture

Issue summary: View changes
Status: Active » Postponed (maintainer needs more info)

This is such a confusing issue...
Anyone still having problems?

If yes, does it belongs to this issue or should it be a new one?
It feels like everyone is just talking past each other.

:)

aspilicious’s picture

Status: Postponed (maintainer needs more info) » Closed (won't fix)

No response in 4 weeks. I suppose this is not an issue anymore. Reopen if needed.

pere orga’s picture

I just wanted to add that to achieve #1, Dynamic View Mode module could be used.

lukus’s picture

Check out https://www.drupal.org/project/entity_view_mode.

You can use it to create an entity view mode and associate it with the entity / bundle you're referencing.