1

Working on a Drupal 7 site.

For a “view block” (or a series of view blocks) in the content section of a content type(s), when is it better to add a specific view block as field to the content type (and set as default view + hide), vs better to configuring the view block to display via the blocks section (and restricting via content type)?

Dot point:

  • Add view a field to one or more content types (in content section)
  • -----Set as default and hide it (same view for all content type)

  • Or Set view to display in block section (or even context)?

  • -----Restrict to content type

Pros and cons I can see:

Block displayed via as a field:

  • View is specific to the content type, no mistaking it

  • If view is used on one or more content types, the block and can be re-arranged without affecting other content types that might use it. Block display via blocks (or context) section

  • Can see at a glance which content types use the view block (if using context, otherwise, its harder)

  • Can’t have two content types have a different arrangements of the blocks (eg using two view blocks). Unless I’m wrong here?

  • Pollutes the blocks section of the backend if using many different content types (where are only used 1-2 times)

  • I can see this makes sense for side bar view or something since it would be used across the majority of the site + it’s not in the content section anyway, not for this though

Can someone advise which direction is better? (and if Drupal 8 way is different?)

3
  • 1
    This is primarily opinion and situational based, like if you're going to have tons of view's, it will pollute the block area as you mentioned, but some people might not mind this. Maybe another con for via as a field, is that you need to use Panels or Display Suite, while the other approach does not require those modules. In addition, there is another method that you didn't mention. You could create a template file for your content types and add your view there using the embed view print views_embed_view('view_name','block_1', $argument);
    – No Sssweat
    Jul 6, 2016 at 1:04
  • (and if Drupal 8 way is different?) it's pretty much the same, except for template files method you will need to use the twig tweak module
    – No Sssweat
    Jul 6, 2016 at 1:06
  • Oh okay thanks. Im assuming no performance hit. And whether the site bulder wants the block arrangement to be configurable... sound reasonable yes? Jul 7, 2016 at 12:17

0

Browse other questions tagged or ask your own question.