Enable view mode for bundle

wdseelig's picture

Is it possible, if multiple view modes are available for particular bundle, to select which view mode will be used?

To be specific, if several view modes are available for the "Page" bundle type, is it possible to select the one that Drupal will use to render a Page?

I think I can do this by using the View module, but am wondering if it is possible to do so without it?

Wyckham

Comments

Suggestions

Lars Bo Jensen's picture

It's not crystal clear, what you mean, but here are some suggestions.

I suppose, you are referring to the view mode at example.com/path-to-the-node, and of course that you are using Display Suite.

Drupal will default to 'default' view mode, unless you choose to control the 'Full content' view mode with Display Suite; then it will default to that.

If you activate the 'View mode per node' option at admin/structure/ds/extras > 'Other' tab, you can select the view mode per node.

With Views, you can take over/create blocks and lists of content and select the view mode. Let your view display 'content' or 'Display Suite' and select view mode of that content.

You might want to check out Panels and Bean, and if you are not familiar with Views, you should practice ;)

If you can describe your use case more precisely, I/we may be able to give you a better answer.

Assigning View Mode to Bundle

wdseelig's picture

Thank you VERY much for this post.

Even though I had read the Display Suite documentation, I somehow had come to believe that I could create my own view mode with the module, enable that view mode for a particular bundle [Page, in my case], and then instruct Drupal to use the view mode I had created when displaying that kind of content. I knew that I could use the Views module to accomplish my objective, but somehow thought that I didn't need an intermediary. Compounding my confusion was the fact that it IS possible to assign my own view mode to a rendered entity.

The sentence in your post that indicated that Drupal will use 'default' view mode unless the user has decided to enable 'Full Content' control cleared this up for me.

So, to summarize what I think I've learned, it is possible to assign a view mode that I have created to a rendered entity, but it is not possible to assign a view mode that I have created to a bundle, like Page.

I don't now how frequently you see questions like the one I asked. [Or, for that matter, whether I am being uniquely dense]. Maybe it would be useful to make the point somewhere in the documentation that Default and Full Content are the only view modes available for bundles?

An experiment with view mode and entities

wdseelig's picture

OK. I did something silly just to explore a bit more how this works.

I created a new content type that I called PageDisplayPage. In this content type, I included an Entity Reference field that would link to a bundle of type Page. Lo and behold, I could use my own view mode [created in Display Suite] to control the display of the node referenced by the Entity Reference field.

So it looks to me like Display Suite works on an instance of a bundle [it might be called an instantiation of a bundle in OOP terms] rather than on a bundle itself. I think that Drupal uses the term "Entity" to refer to the instantiation of a bundle, so it might be correct to say that Display Suite provides tools to control the display of Entities.

You're welcome :) You called

Lars Bo Jensen's picture

You're welcome :)

You called it silly yourself, so I guess I don't have to point it out, but: displaying one content type through another, like you do with entity reference, really is a silly solution (if the 'PageDisplayPage' content type only displays the referenced entity).

I guess, what you need is the 'view mode per node' option as already described:

If you activate the 'View mode per node' option at admin/structure/ds/extras > 'Other' tab, you can select the view mode per node.

– or to edit the default or the 'full content' display as you please.

Display Suite

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week