Modern UI helper functions
Managed by | Updated .
Background
There are several helper functions that are available for use within Modern UI hook scripts and Freemarker templates.
removeParam(qs, paramNames)
Removes a set of parameters from a query string.
Parameters
qs
: query stringparamNames
: list of parameters to remove from string
Freemarker macro
The following macro can also be used to call this function:
<#macro RemoveParams params=[]>
<#-- Removes specified parameters from the query string -->
<#local qs><#nested></#local>
<#compress>
${removeParam(qs, params)}
</#compress>
</#macro>
Example
Return a link that strips off all the faceted navigation parameters (and the start rank) from the query string:
<a href="${question.collection.configuration.value("ui.modern.search_link")}?<@custom.RemoveParams params=question.selectedCategoryValues?keys + ["start_rank"]">${QueryString}</@custom.RemoveParams>">Clear selected filters</a>
facetScopeRemove(qs, paramNames)
Utility method used in faceted navigation when building facets breadcrumbs. Used to remove a given list of facet constraint from the facetScope parameter of the query string.
Parameters
qs
: query stringparamNames
: list of parameters to remove from string
Freemarker macro
The following macro can also be used to call this function:
<#macro FacetScopeRemove params=[]>
<#-- Removes specified parameters from the query string -->
<#compress>
<#local qs><#nested></#local>
${facetScopeRemove(qs, params)}
</#compress>
</#macro>
Was this artcle helpful?