Skip to content

Blocks and views

Show a block on chosen sites, and scope views and reference fields to the current site.

Blocks by site

Block placements are shared: every site that uses a theme shows its blocks. To limit a block to some sites:

  1. Open the block's Configure form in Block layout.
  2. Under Visibility, open the Site tab.
  3. Check the Sites the block shows on.
  4. Click Save block.

With no site checked, the block shows everywhere. Negate the condition shows it everywhere except on the checked sites. A block limited to sites does not show on the hub.

A content block belongs to sites like other content. Placed for every site, it renders only on the sites it belongs to; see Content on sites.

Views

Views of site content (content, media, content blocks, terms, users) offer two handlers:

  • The Sites filter narrows the rows to the chosen sites. Exposed, it offers the sites the viewer can access. Expose canonical site checkbox adds Originating content only, which keeps the content whose canonical site is among the chosen ones.
  • The Sites summary field shows each row's canonical site and the number of further sites, with a list on click.

Both have options to hide them off the hub, or when the viewer can access one site only.

Each view has a Filter by site option in its query settings (Advanced > Query settings):

Option On a site's hostname
Site default Scopes the rows to the site's content when the site's Filter listings by the active site is on.
Filter by the active site Always scopes the rows to the site's content.
Do not filter by site Never scopes the rows.

The admin overviews of content, media, content blocks and people list only the site's content on its hostname either way. On the hub, a view at Site default lists every row for a user with Administer sites until a site is chosen in its Sites filter; a user who works on some sites sees the content of those sites.

For caching, Tag based, per site drops a cached view of one site's content only when that site's content changes; core's Tag based drops it on any change of the content type.

Site filtering

The Site filtering setting of a site holds two switches. Set them on the site type for all sites, or per site on its Site filtering section.

  • Filter listings by the active site: views left at Site default list this site's content only. Entity queries that check access, like JSON:API collections, follow it too.
  • Filter references by the active site: reference fields at Site default offer and show only this site's content. References without a Filter by site option, like the target of a menu link, offer only this site's content.

A reference field to site content has its own Filter by site option on its field settings form:

Option Effect
Site default Follows Filter references by the active site. A new field starts here.
Filter by the active site Always offers and shows only the current site's content.
Do not filter by site Offers and shows every item of the user's sites, whatever the site's setting.

No option widens the choice beyond what the user reads: a reference field offers content of the sites the user takes part in, plus the current site on a site's address. Content that belongs to no site needs View unassigned content; Administer sites offers everything.

A field that references users starts at Do not filter by site, so an editor can pick an author who is not a member of the site.

Upgrading from 1.0.0-beta1

A field saved with Do not filter in 1.0.0-beta1 still followed the site's setting. After the upgrade it shows Site default. To keep it unfiltered, choose Do not filter by site and save the field settings again.