1

We have a requirement where pages in our existing Wiki Library under the Enterprise Wiki Site template need to have the Page Rating functionality to be visible on each wiki page. Although this is available by default if we use the “Pages” library, we need this to also be available within new Wiki Page Libraries.

How can we achieve that?

2 Answers 2

0

You can manually add a new column "Rating (0-5)" to Wiki Page Library (via Library settings). However you cannot add the fields to the layouts. This means users would have to edit the content of the page, then separately edit the Rating (0-5) at View All Pages view of the library.

Wiki Page Library doesn't support Page Layout. So we cannot amend the layout to show different properties, like Rating (0-5), at the page content.

0

Apparently, this is not possible without development effort. There are a number of articles (apologies for non-citation) that explain how the Pages library leverages Publishing Features and the accompanying page layouts to expose the ratings on each page (not only in the list view).

However, as Mark mentioned in his response to this post, the Wiki Library uses Text Layouts (not Page Layouts) and only has the ability to turn on Ratings, but you cannot expose this rating web part on each page. Traditionally, the ratings/stars are granted through the list view.

So, we used javascript to accommodate this requirement. We created a new custom list and called it Feedback. Then, we created a few columns that simply request a rating 1-5 on various aspects of the page (nothing special; straight out-of-box choice columns here as well as a few comment columns).

Then, in addition to the choice and comment columns, we created a text column 'KTPage' to collect the URL and the Page for which they are providing feedback and used javascript in a CEWP on the NewForm.aspx to automatically fill that column with the referring page.

Finally, we published the link to the NewForm.apsx form on the current (left) nav menu. Although it is not a pretty series of stars like we hoped, the link is visible wherever the current (left) navigation is visible. Users can provide feedback on any of the pages in the Wiki Library and the information is collected in the new/custom Feedback list.

The javascript we used is below.

    <script src="https://<sharepointsite>/sites/Wiki/SiteAssets/jquery-1.12.0.js"></script>
    <script src="https://<sharepointsite>/sites/Wiki/SiteAssets/sputility.js"></script>
    <script>
    // wait for the window to load
    $(window).load(function () {
    // document.referrer is native javascript and will return the entire url of the last page visited.
    var url = document.referrer;
    // the command below will parse out an array of strings separated by '/'.  Then it will return the 'last' element (plus one character).
    var filename = unescape(url.substring(url.lastIndexOf('/')+1));

    try {
    // SPUtility.js is required for the following two commands to work

    // These two commands are the ones that set the values into the SharePoint list fields.
           SPUtility.GetSPField('Title').SetValue(filename).MakeReadOnly();
           SPUtility.GetSPField('KTPage').SetValue(url).MakeReadOnly();
} catch (ex) {

    // Alert with a dialog box.  Expect to see this when you reference a column that doesn't exist.

            alert(ex.toString());
        }
    });
    </script>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.