FullCalendar Solr provides integration with the FullCalendar JavaScript library to provide a Year Calendar View display formatter that is compatible with Search API.
The calendar highlights dates associated with content. It also features a year dropdown containing only years with results. This module is compatible with the Search API Solr and Facets modules.
Note: This formatter is not compatible with regular content Views.
This module requires the following modules:
The Search API backend needs to support the search_api_facets
option.
- Clone this repo into
drupal/web/modules/contrib
or install using Composer. - Enable the module at
Admin > Extend
or use Drush.
- At
/admin/structure/views
, clickAdd view
. UnderView settings > Show
, select a Solr index. - Create a Page.
- Set the Display Format to
FullCalendar Solr
. - Configure the page path such that the last component is 'year'.
(e.g.
/a/b/c/year
) - Under
Fields
, add a string field containing a date in YYYY-MM-DD format. Any dates not in YYYY-MM-DD format will not be displayed in the calendar.- Ensure that the date field selected is an indexed field by the Solr Index chosen.
- Under
Advanced > Contextual Filters
, select a filter containing year values in YYYY format. - Edit the year contextual filter.
- Under
When the filter value is NOT available
, selectProvide default value
. - Set the type to
Raw value from URL
- Set the Path Component to the index of where
year
is located in the path. (e.g. for/a/b/c/year
, the Path Component should be set to 4)
- Under
- Under
Format > FullCalendar Solr Settings
, set the Date Field to the field created in step 5 and the Year Field to the field created in step 6. - Add any additional view configurations as needed.
- Save the view.
The year calendar can be configured to redirect to a day view when a highlighted date is clicked.
- Edit the year view page. Under
Format > FullCalendar Solr Settings
, check theNavigation Links to Day View
option and save. - Click
Add > Page
. This will be the new Day View. - Select a display style. (One that is not
FullCalendar Solr
) - Under
Advanced > Contextual Filter
, add a filter containing a string date in YYYY-MM-DD format. This should be the same as the date field used in the year view.- If the date field is not available, try adding the field to the Search API Index.
- Configure the page path. The path of this view should be the same as the
path of the Year View except the last URL component is 'day' instead of 'year'
(i.e. if the year view has path
/a/b/c/year
, the day view must have path/a/b/c/day
). - Add any additional view configurations as needed.
- Save the view.
If a highlighted date has only one result, the year calendar can redirect to the result itself instead of the day view.
- Prerequisites: Navigation Links are enabled and a day view is set up. (See Creating a Day View)
- Edit the Year View page.
- Under
Fields
, add a field containing an item path or URL. - Under
Format > FullCalendar Solr Settings
, check theLink to Item
option. - The
Item URL Field
dropdown should now be available. Select the field containing the item path or URL. - Save the formatter settings.
- Save the view.
This is a method of dynamically generating a link to the calendar view when
a year is required (e.g. the default value of the year contextual filter is
set to Raw value from URL
). The block can be set to link to the oldest/latest
year with results.
- Edit the calendar view and select
Add Block
. - Under
Block settings
, set theBlock category
toLists (Views)
. - Under
Format
, set the format toUnformatted list
and select to showFields
. - If your calendar view has any contextual filters other than the year,
add them under
Contextual filters
.- In the settings of each filter, under
When the filter value is NOT available
, selectProvide default value
. - Set the type to
Raw value from URL
and set the path component number based on the path of where this block will be placed.
- In the settings of each filter, under
- Under
Fields
, add a year field containing years in YYYY format. - Edit the year field.
- Set the
Thousands marker
toNone
. - Go to the
Rewrite results
section.- Check
Override the output of this field with custom text
. - Under
Text
, customize your link text. E.g.Calendar View
. - Check
Output this field as a custom link
. - Fill in the
Link path
field. Model this after the path of your calendar view using the Replacement patterns. E.g./node/{{ arguments.field_member_of }}/year/{{ year }}
. - If using an absolute path, check
Use absolute path
. - (Optional) Set the
Prefix text
andSuffix text
options.
- Check
- Go to the
No results behavior
section. CheckHide if empty
andHide rewriting if empty
.
- Set the
- Under
Pager
, set the pager toDisplay a specified number of items
. Set theItems to display
field to 1. - Under
Filter criteria
, add<Year Field> is not empty
. - Under
Sort criteria
, add the year field. Set the sort order to ascending to get the oldest year, or descending to get the latest year. - Place the block within a view that has the contextual filters used by the block.
The year calendar doesn't display all dates with content
- Try going to
View settings > Pager options
, and set the Items per page` option to 365.
The calendar link block displays multiple links
- This is likely because some of the results have more than one year value.