Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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:

        while(items.moveNext())
    {
        try
        {
            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>';
        }
        catch(err)
        {
            menuNavContent = err.name;
            contentNavContent = err.message;
        }
    }

    menuNavContent += '</ul>';
    menuNavContent += '</div>';
    $('#menuNav').html(menuNavContent);

    contentNavContent += '</ul>';
    contentNavContent += '</div>';
    $('#contentNav').html(contentNavContent);
}
share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

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.

share|improve this answer
    
nice 1, I read about it somewhere but wasn't coming into my mind :) ! –  Muhammad Raja May 3 '13 at 17:53
    
thank you for the info –  Jason May 3 '13 at 18:22
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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