Fallback is a powerful widget setting that lets you alter the current widget query when no results are found. You can also set multiple fallbacks that will be attempted in order.
In this example, the widget will:
- Show starred results from my group
- If none found: show any results from my group
- If none found: show starred results from the Marketing group.
<widget type="events">
<arg id="group">me</arg>
<arg id="only_starred">true</arg>
<arg id="max">5</arg>
<arg id="fallback">
<arg id="only_starred">false</arg>
</arg>
<arg id="fallback">
<arg id="group"></arg> <!– empty previous group=me setting –>
<arg id="group">Marketing</arg>
<arg id="only_starred">true</arg>
</arg>
</widget>
One thing to note: certain settings (like group) are additive, but you can clear out previous values by first setting an empty value in your fallback.
Fallback is commonly used when building search results page. For example, this widget first checks for the verbatim search query in the first/middle/last name fields, and then falls back to a regular search if none found.
<widget type="profiles">
<arg id="type">Faculty and Staff</arg>
<arg id="filter_mode">any</arg>
<arg id="filter" name="firstname" action="contains"><xphp var="search" type="GET"/></arg>
<arg id="filter" name="middlename" action="contains"><xphp var="search" type="GET"/></arg>
<arg id="filter" name="lastname" action="contains"><xphp var="search" type="GET"/></arg>
<arg id="filter" name="name" action="matches"><xphp var="search" type="GET"/></arg>
<arg id="fallback">
<arg id="filter"></arg><!– clear out all the filter settings –>
<arg id="search"><xphp var="search" type="GET"/></arg><!– use a normal search –>
</arg>
</widget>