Collections with Search Blueprints

7.4 U88+ Beta Feature

When you create a search blueprint, a collection provider is registered automatically. Assets matching the blueprint’s query and configuration are added to the collection.

important

Only content registered with Liferay’s Asset Framework is returned by the blueprints collection provider.

Search blueprints are registered as collection providers.

To use a search blueprint’s collection provider,

  1. Enable the beta feature flag for LPS-129412.

    A blueprint’s collection provider is registered only when Liferay starts or the blueprint is published. If you have existing blueprints when you enable the feature flag, you must edit each blueprint and save it to register its collection provider.

  2. Create a blueprint.

  3. In a content page’s editor, add the Collection Display fragment.

    You can also use the collection provider when adding collection pages.

  4. Choose the blueprint’s collection provider in the Collection Provider field.

As with other collections, you can filter the blueprint-driven collection by keywords or categories with a collection filter.

Example: Showing Future Events

Create calendar events and configure a blueprint to return only events that happen in the future. Display the events on a content page using the collection display fragment:

  1. Enable the beta feature flag for LPS-129412.

  2. Create a page and add the Calendar widget to it.

  3. Create three calendar events:

    • Past Event: configure it to happen in the next five minutes and last 15 minutes (or less).
    • Future Event 1: Make an event that starts in the future.
    • Future Event 2: Make another event that occurs in the future.

    Three events are added to the Calendar widget.

  4. From the Applications menu (Global Menu), open Blueprints.

  5. In the Elements tab, add a new custom element with this JSON:

    {
       "description_i18n": {
          "en_US": "Limit results to only future events, using the endTime field."
       },
       "elementDefinition": {
          "category": "filter",
          "configuration": {
             "queryConfiguration": {
                "queryEntries": [
                   {
                      "clauses": [
                         {
                            "context": "query",
                            "occur": "filter",
                            "query": {
                               "range": {
                                  "endTime": {
                                     "gt": "${time.current_date|date_format=timestamp}"
                                  }
                               }
                            }
                         }
                      ]
                   }
                ]
             }
          },
          "icon": "filter",
          "uiConfiguration": {}
       },
       "title_i18n": {
          "en_US": "Limit Results to Future Events."
       },
       "type": 0
    }
    
  6. In the Blueprints tab, build a blueprint to match only calendar events that are in the future:

    • Title: Enter Future Calendar Events Provider.
    • Query Settings: select Calendar Events in Searchable Types.
    • Query Elements: add the Limit Results to Future Events element.
  7. Save the blueprint.

  8. From the site menu (Site Menu), add a content page called Upcoming Events.

  9. Add the Collection Display fragment to the page and select the Future Calendar Events Provider Collection Provider.

    Configure the collection display fragment to show a bullet list.

  10. Publish the page, and the future calendar events appear.

Only the future events are displayed in the collection display fragment.

Leverage blueprints to return your results dynamically, and reap the benefits of the fragments toolbox to lay out the page.

Capabilities

Product

Contact Us

Connect

Powered by Liferay
© 2024 Liferay Inc. All Rights Reserved • Privacy Policy