Recently modified pages targeting specific tags
- Applies to:
- All MindTouch Versions
- Role required:
- Draft Contributor
Prerequisite
Depending on the articles you want to surface, the Expert default classifications may not suffice. Use custom classifications to control which articles to surface.
Part 1: Create your template
- Navigate to Site tools > Dashboard > Site Administration > Template Directory (/Template:).
- Navigate to Template:Custom.*
- Click New.
- Save the page as TaggedArticlesWidget.
* For this example, we assume your template is located at /Template:Custom/TaggedArticlesWidget.
Do not modify or add any templates in Templates:Expert.
Part 2: Add DekiScript to your template
Now that you have created a new template, you are ready to add the DekiScript code block to your page. Perform the following steps:
- Open your TaggedArticlesWidget template in Edit mode.
- In the editor toolbar, click the Styles drop-down list and select DekiScript.
- Paste the following into the DekiScript code block:
var query = "tag:stage:draft"; var pages = wiki.getSearch(query, 10, "-date"); <div class="widget-tagged-articles"> <ul> foreach (var pg in pages) { <li> <a href=(pg.uri)>pg.title</a> <span class="date"> "( edited "; date.format(pg.date,"ddd MMM dd, yyyy"); " )" </span> </li> } </ul> </div>
- Locate the var query.
- Modify the var query to reflect the classification and tag of articles you want to display (for example replace "tag:stage:draft" with your own classification "tag:language:english" ).
- Click Save.
You must specify both the classification and tag, or the code will not return any results. If you are unsure, review your classifications and tags in the control panel (under System Settings > Classifications).
Part 3: (Optional) Customize the look and feel of your template
Now that you have created your template and added the DekiScript, you have the option to customize the way the date is displayed in your list. Perform the following to add CSS to your template:
- Open your TaggedArticlesWidget template in Edit mode.
- Insert the cursor at the bottom of the page.
- In the editor toolbar, click the Styles drop-down list and select CSS.
- Paste the following into the CSS code block:
.widget-tagged-articles .date{ margin:0 0 0 5px; font-size:10px; font-style: italic; color:#999 }
- Modify the CSS as desired.
- Click Save.
If the cursor only shows up in the DekiScript block, press Shift+Enter to escape it.
Part 4: Add your template to a page
Now that your template is complete, you are ready to embed it into an Expert page. While most users will find this information valuable on your homepage, you may embed your template into any Expert page:
- Navigate to the page on which you want to display the list.
- On the Expert toolbar, click Edit.
- Locate where on the page you want to add the widget (even in a table, if you want).
- Add the following DekiScript and click Save.
template("TaggedArticlesWidget");