Hi there - I'm interested in allowing content editors to select the View mode associated with a block reference. This is similar to how when you are creating a View, you can select the View mode in the "Show" settings when creating lists of content. Has anyone prototyped anything like this or have some ideas on how this would be best architected?

Comments

R.J. Steinert created an issue. See original summary.

R.J. Steinert’s picture

StatusFileSize
new2.48 KB

This is Bean centric, but something like the attached patch.

R.J. Steinert’s picture

StatusFileSize
new1.96 KB

Here's another version of that patch. It removes some cruft and uses a consistent method for getting available view modes.

R.J. Steinert’s picture

StatusFileSize
new1.89 KB

Here's another version of that patch. Less cruft again.

rudiedirkx’s picture

If it requires Bean, it's not a patch, but a separate module. Standard blocks don't have view modes. Beans are entities. Why not use Entity reference?

R.J. Steinert’s picture

All good points and we could certainly make this a separate module. I believe that the issue with using entityreference module is that sometimes the editors want to reference a Bean Block, other times they want to reference a View Block. Utilizing this patch we get Drupal closer to giving editors an MVC like experience. The blockreference field becomes a Controller that editors use to combine a Model (the Bean Block) and display it with a View (the View Mode) of their choice. If an editor wants to include a Collection View, they use the Views module as the Controller that manifest itself as a Block that contains a Collection of Models (the Filter options), the Collection View (the Style plugin chosen), and the Item View (the View mode chosen for items).

Ultimately I would like to see a workflow as follows...

1) User selects View, maybe referred to as Widget which is generated from a list of Style plugins and View modes.
2) User adds View specific configuration (ie. sort order in the case of a Table).
3) Given the type of Widget (Item View or Collection View), user is asked what Model or Models to place in the View.

That's just an idea at the moment, for now I think this patch (or separate module) could be improved by only displaying the View Mode select if a Bean is selected.

rudiedirkx’s picture

Wow, you're using the term MVC very flexibly =)

Since the view mode is part of the spefici field item, not the global formatter config, it's slightly harder to make it a separate module. I missed that before. You'd need a custom widget, custom formatter and alter the schema.

Some patch code review:

  • VARCHAR can be 255, always. No reason to calculate an optimum.
  • If you're altering the schema, you need an update hook to actually create the db column.
  • You need some module_exists('bean') in there.

I'm very curious to see your end product. If it's well done and unobtrusive, I might patch it, but a separate module is the safer bet.

oskar_calvo’s picture

Hello,

I'd like to know what happens with this patches? Can be used or they required more code?

Thanks.

Oskar

romixua’s picture

Assigned: Unassigned » romixua
Issue tags: +epam-contrib-2019.03
romixua’s picture

romixua’s picture

romixua’s picture

Assigned: romixua » Unassigned
Issue tags: -epam-contrib-2019.03