Create or Update a View¶
Drupal Views allow you to get your content in Islandora to display on your site in pages or as posts, lists, blocks, etc. Views are powerful and filter content from Islandora to enable you to present content in interesting and exciting ways.
Before you start¶
- The following How-To assumes that you are using the (optional) Islandora Defaults configuration. This configuration is deployed automatically if you build your Islandora site using the Ansible Playbook, ISLE with Docker-Compose, or are using the sandbox or a Virtual Machine Image
- This How-To assumes familiarity with Drupal terms such as Node, Content Type, and Media.
How to modify an existing view¶
Islandora Defaults ships with some views already created and turned on. The Islandora 8 home page displays content items that have been added to Islandora. This view is named Frontpage and it lists items that meet the following filter criteria:
- The item is in the published state.
- The checkbox Promoted to front page is selected.
This view will display all content items added to Islandora, as the checkbox Promoted to front page is on by default.
As you develop your Islandora Web site it is likely that you will need to change the default behaviour of the Frontpage View. As an example, the following describes how to edit the Frontpage page view to only show content items and not collections.
For this example, we added six collection items to Islandora. In total there are eight items in the repository. In addition to the six collection items, there is one audio item and one image item.
- Using your Web browser, open the Islandora front page
- For this example, on the front page we can see that Islandora displays a 'Collection' first as this is the most recently added item.
- To edit the front page view, hover over the view (Frontpage view) and select Edit view when displayed.
- Select Add under the filter criteria section.
- We do not want to display collections, so we need to add a filter criteria that does not filter for the Islandora model type 'Collection'
- Select Model from the list and then Apply (all displays).
- Select Islandora Model to select filters on Islandora model types and select Apply and continue.
- Select the operator Is none of and the Collection model (autocomplete should work here to help you). To finish click Apply (all displays).
- Save the view. Now the 'Frontpage' View does not display collections.
How to create a new view¶
For this example, we create a new view that only shows collections. It will be created as a block that will only display on the front page. We will add the new collection list block below the existing frontpage view that lists items.
- Using your Web browser, open the Islandora 8 front page
- Navigate to Administration >> Structure >> Views (~/admin/structure/views)
- Create a new view by selecting Add view
- Name the view and select Create a block. Give the block a title and decide how you want it to display (Grid, Table, List, Paging). To progress, select Save and edit.
- Customise the view format and sorting as required.
- Add a filter criteria to only show the Islandora model type of 'Collection' and Save the view.
- To place the view on front page, the new block must be added to the 'Main page content' area (using 'Block layout') and set to display on the front page.
- Navigate to Administration >> Structure >> Block layout (/admin/structure/block). Under Main content select Place block
- Find the new block, 'Collection List' and select Place block.
- Restrict the block to only display on the frontpage by adding the text '
' to the Page vertical tab. Then select Save block.
- Review the block placement and move if required.
- The 'Collection list' now only displays on the front page. It displays below the Main page content.