·¬ÇÑÉçÇø

Brightspot CMS Developer Guide

Multi-site considerations


In a multi-site environment, you may have use cases where queries need to reflect the site context. For example, the Recent Activity widget and search panel query for objects that are owned by the site that the user selects in the dashboard.


The class provides methods to set a site’s properties, site owner of an object, and access to an object from other sites. However, as a best practice, administrators should perform these functions in Brightspot. See Creating a site and Assigning permissions to content on multiple sites for more information.


In a multi-site environment, you may have use cases where queries need to reflect the site context. For example, the Recent Activity widget and search panel query for objects that are owned by the site that the user selects in the dashboard.

By default, a query searches for objects across all sites unless otherwise restricted. For example, a visitor requested an article, and you want to display 10 associated articles. You can use a query field in the model, run the query in the view model, and display the results in the view. The view model must retrieve only articles owned by the site the visitor is at, or articles to which non-owning sites have been granted access. To accomplish this filtering, the view model class can use the method in the query that gets related articles.

Query query = model.getQuery(); 
Site site = model.as(Site.ObjectModification.class).getOwner(); 
if (site != null) query.where(site.itemsPredicate 
List<Article> relatedArticles = query.select(0,10).getItems(); 
  • Gets the query from the model, the Article object retrieved by the visitor.
  • Gets the owner site of the article.
  • Uses the site.itemsPredicate method in the query if the article is owned by a user-created site. This method returns a predicate that filters out any articles that are not owned by the site, or articles to which non-owning sites have not been granted access. If the site is null, the article is owned by the Global site, which has access to all objects in Brightspot.
  • Executes the query, returning the first 10 articles retrieved.

Previous Topic
Site settings
Next Topic
Adding custom styling and scripting
Was this topic helpful?
Thanks for your feedback.
Our robust, flexible Design System provides hundreds of pre-built components you can use to build the presentation layer of your dreams.

•
•
•
Brightspot is packaged with content types that get you up and running in a matter of days, including assets, modules and landing pages.

• Content types
• Modules
• Landing pages
Everything you need to know when creating, managing, and administering content within Brightspot CMS.

• Dashboards
• Publishing
• Workflows
• Admin configurations
A guide for installing, supporting, extending, modifying and administering code on the Brightspot platform.

• Field types
• Content modeling
• Rich-text elements
• Images
A guide to configuring Brightspot's library of integrations, including pre-built options and developer-configured extensions.

• Google Analytics
• Shopify
• Apple News