I have an ECMA script that I'm using to build a site directory (Thank you Bill Simser). I'm trying to add additional information such as the template the site is using, and not having much luck finding all of the properties I can utilize.

I'm attempting to add something like:

var template = item.get_template();

but this is not a valid property for ecmascript.

here is the script I'm using:

            var item = items.get_current();
            var itemUrl = item.get_serverRelativeUrl();
            var title = item.get_title();
            var template = item.get_template();
            var lastItemModified = getModifiedDateString(new Date(item.get_lastItemModifiedDate()));

            menuNavContent += '<li>';
            menuNavContent += '<a href="' + itemUrl + '">' + title + '</a>';
            menuNavContent += '</li>';

            contentNavContent += '<div style="cursor:pointer;" onclick="';
            contentNavContent += "location.href='" + itemUrl + "';";
            contentNavContent += '">';
            contentNavContent += '<li class="theme_blue">';
            contentNavContent += '<div>';

            contentNavContent += '<div class="tileTitle">' + title + '</div>';
            contentNavContent += '<div class="tileSubtitle">' + lastItemModified + '</div>';

            contentNavContent += '</div>';
            contentNavContent += '</li>';
            contentNavContent += '</div>';
            menuNavContent = err.name;
            contentNavContent = err.message;

    menuNavContent += '</ul>';
    menuNavContent += '</div>';

    contentNavContent += '</ul>';
    contentNavContent += '</div>';

The webTemplate property is not exposed by the SP.js in 2010. (It is however in 2013: http://msdn.microsoft.com/en-us/library/jj838541.aspx). However, there is a JS variable written to the page with the web template name: g_wsaSiteTemplateId. Without any server-side code, etc., that would be the only identifying mark of the template.

  • nice 1, I read about it somewhere but wasn't coming into my mind :) ! – Muhammad Raja May 3 '13 at 17:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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