Skip to main content
NICE CXone Expert
Expert Success Center

Popular pages list in DekiScript

Embed a custom-styled list of the top ten popular articles into an Expert page.

Part 1: Create template

  1. Navigate to Site Tools > Dashboard > Site Administration > Template Directory.
  2. From the Expert Toolbar, select New.
  3. Enter a name for the template in the Template:Page Title field, for example, "Popular Pages".
  4. From the Editor Toolbar, select Style > DekiScript.
  5. In the Enter Dekiscript field, paste the following DekiScript code:
    var uri = site.api & 'pages/popular' & { limit: 10 };
    var api = wiki.api(uri);
    
    <div class="widget-popular">
        <ul>
        foreach(var pg in api['page'] ) {
            <li>
                web.link(pg / 'uri.ui', pg / 'title');
                var viewcount = num.cast(pg / 'metrics/metric.views');
                <span class="viewcount">
                    " (";
                    num.format(viewcount,"###,###,###");
                    " views)";
                </span>
            </li>
        }
        </ul>
    </div>
    
  6. To customize the style of the template (optional), select Style > CSS from the Editor Toolbar and enter custom CSS into the field. For example:
    .widget-popular .viewcount {
        margin:0 0 0 10px;
        font-size:10px;
        color:#999;
    }
  7. Click Save and you will see the DekiScript block and CSS block (optional) in view mode.
    File:01MindTouch_Help_Center/Developer_Guide/DekiScript/Adding_a_list_of_Popular_Pages/popular_pages_code_example.png

Part 2: Embed template on Expert page

  1. Navigate to the page where you want the template embedded and open it in Edit Mode.
  2. Place your cursor in the desired page location and select Style > DekiScript.
  3. In the Enter Dekiscript field, paste the following DekiScript code, making sure that the text in quotes matches your template URL:
    template("Popular_Pages");
  4. Click Save.

Example with page view count

 

 

  • Was this article helpful?