subtree

Type: string
Default: ''
Context: prediction, questions

About this parameter

Control whether only pages under a certain branch of the site should be displayed. For example: data-subtree="/gata--park/" then only shows pages under the Street & park tab. The parameter makes it easy to set up recommendations on review pages or web parts.

If you want to add several strings to be used when selecting pages, you can separate them with a "," This example shows pages both under Street & park, but also Housing:

<div class="rek-prediction" data-subtree="/science/,/accommodation/"></div>

It is possible to automate how these are created by using: data-userootpath="true" data-rootpathlevel="1". So please see these parameters as well: Userootpath

Make sure a url starts with the subtree

By adding a caret "^" before the subtree it will be required that the url starts with exactly that path:

<div class="rek-prediction" data-subtree="^/science/"></div>

Match an exact path

If you want the filter to only apply when the URL matches an exact path, you can add a dollar sign "$" at the end of the subtree. This ensures that only the specified path itself is included, without subpages.

<div class="rek-prediction" data-subtree="^/science/$"></div>

In this example, only the exact path /science/ will match, while URLs like /science/biology/ or /science/article1/ will not.

This is especially useful when working with Questions & Answers, where you often only want to show questions created for the current page itself, not from subpages.

Usage examples

<div class="rek-prediction" data-subtree="school"></div>