This template will provide you will the most popular pages in a page tree per the view counts of those pages within a given path. It allows you to control the number of items returned, as well as how deep to drill down the tree.
PERFORMANCE: For best performance it is a good idea to keep your max results and depth as small as needed.
| Version | Date | Author | Description |
| 1.0 | 22/08/2009 | rberinger | Initial template |
| 1.0.a | 28/08/2009 | rberinger | Change from using div id's to div classes |
| 1.1 | 19/03/2010 | neilw | Use @pageid to extract pages from wiki.tree(), for more reliable operation with pages with special characters in their names |
For all the examples on this page, the code is shown before the working example. The code is shown with the syntax extension, and looks like this:
WhatsPopular{arguments}
This means that the actual code on the page should be enclosed in a Dekiscript block. If you want to copy the code from this page, then use the same procedure as described in steps 2-4 above.
Simply create a dekiscript block where you would like to have the Whats New list appear and make a call to the template. See the example below.
| Name | Type | Default | Description |
| title | str | Whats New! | This string will become the title of the results |
| path | str | page.path | The path to serve as the starting point |
| max | num | 10 | The maximum number of results to display |
| depth | num | 10 | The tree depth to look for pages (just like wiki.tree) |
| reverse | bool | true | Reverse the sort order |
| blockstyle | str | See Template | Any valid in-line css. Controls container that wraps entire template |
| titlestyle | str | See Template | Any valid in-line css. Control Title Section |
| bodystyle | str | See Template | Any valid in-line css. Controls the body or content section. |
The following example limits the results to the top 5 most popular pages. The styling also shrinks the template and centers within the container.
WhatsPopular {
title: 'Most Popular App Catalog Entries',
path: 'app catalog',
max: 5,
depth: 1,
blockstyle: 'width:50%; margin: 0 auto;'
}
The following example limits the results to the top 10 most popular pages and will evaluate pages down 2 levels from the start page.
WhatsPopular {
title: 'Most Popular App Catalog Entries',
path: '/DekiScript/FAQ',
max: 10,
depth: 2
}
None.
Everyone in the MindTouch Community Forum
/* WARNING
* WARNING: this community-contributed template is not fit for production use as it performs a complete db-scan with every invocation
* WARNING
*/
// Parameters:
// title: The title text
// Path: pathe to the starting page
// max: Maximum number of items to list
// depth: The level of sub page to evaluate
// reverse: Reverse to sort order
// blockstyle: Any valid in-line styles. Affects container that wraps entire template
// titlestyle: Any valid in-line styles. Affects the title section
// bodystype: Any valid in-line styles. Affects the body section
/*
In a dekiscript block:
WhatsPopular{ title: 'My Popular Pages',
path: '/resources',
max: 5,
depth: 2,
reverse: true,
};
Vesion History: 1.0 - Initial release
1.0.a - Changed from using div id's to div classes
1.1 - (neilw) Changed to using @pageid to find the pages from wiki.tree()
*/
var ttl = ($0 ?? args.title ?? 'Whats New!');
var path = ($1 ?? args.path ?? page.path);
var maxnum = ($2 ?? args.max ?? 10);
var depth = ($3 ?? args.depth ?? 10);
var reverse = ($4 ?? args.reverse ?? true);
var blockstyle = ($5 ?? args.blockstyle ?? '');
var titlestyle = ($6 ?? args.titlestyle ?? '');
var bodystyle = ($7 ?? args.bodystyle ?? '');
var pageviews = 0;
var pagelist = [];
var pxml = wiki.tree(path,depth);
foreach(var pid in xml.list(pxml, "//a/@pageid")) {
let p = wiki.getpage(num.cast(pid));
let pagelist ..= [ {title: p.title, uri: p.uri, viewcount: p.viewcount } ];
}
let pagelist = list.sort(pagelist, 'viewcount', reverse);
<div class="whtspop" style=(blockstyle)>
<div class="whtspoptitle" style=(titlestyle)>
ttl;
</div>
<div class="whtspopbody" style=(bodystyle)>
foreach(var p in pagelist) {
if(__count >= maxnum) {break;}
if(p.uri) {
web.link(p.uri, p.title); <span style="font-size: x-small;">;' - (' ..num.format(p.viewcount,'##,#') ..' Views)'; </span> <br/>;
}
}
</div>
</div>
// styles
<html>
<head>
<style type="text/css">"
div.whtspop {
width: 100%;
}
div.whtspoptitle {
background-color: rgb(234, 234, 234);
text-align: center;
padding: 2px;
font-weight: bold;
font-size: 16px;
border-style: outset;
}
div.whtspopbody {
background-color: #FFF;
padding: 2px;
border-style: solid;
border-width: 1px;
text-align: left;
}
"
</style>
</head>
</html>
None.
| Images 0 | ||
|---|---|---|
| No images to display in the gallery. |
Copyright © 2011 MindTouch, Inc. Powered by