Wednesday, May 9, 2012

Delete Selected Item using ECMA


function DeleteSelectedItem() {

    var clientContext = SP.ClientContext.get_current();

    var currentlibid = SP.ListOperation.Selection.getSelectedList();


    if (currentlibid == null) {
        alert('Please select at least one item and try again.');
        window.location.href = window.location.href;
    }
    else {
        var oList = clientContext.get_web().get_lists().getById(currentlibid);
        var selectedItems = SP.ListOperation.Selection.getSelectedItems(clientContext);

        if (selectedItems == '') {
            alert('Please select at least one item and try again.');
            window.location.href = window.location.href; //window.location.reload(true);// = window.location.pathname;
        }
        else {
            if (confirm("Do you want to delete selected items?")) {
             // RecycleSelectedItems();
            /*  var myItems = '';

                for (var i in selectedItems) {

                    myItems += '|' + selectedItems[i].id;

                }
                myItems += '^' + window.parent.location.href;


clientContext.executeQueryAsync
             (
             function (sender, args) {


                 STSNavigate('/_layouts/EXP.FS.DeleteFiles/DeleteFile.aspx?Items=' + myItems);


             }
           

 

             );*/
             
           // DeleteSelectedItem();

                var myItems = '';

                for (var i in selectedItems) {

                    myItems += '|' + selectedItems[i].id;

                }
                myItems += '^' + window.parent.location.href;
               
                var options = SP.UI.$create_DialogOptions();
 
// options.url =getPageName+'?Items='+ myItems;
        options.url = '/_layouts/EXP.FS.DeleteFiles/DeleteFile.aspx?Items='+ myItems;
        options.width = .5;//500;
        options.height =.5;// 400;
        options.dialogReturnValueCallback = Function.createDelegate(null, CloseCallback);
        SP.UI.ModalDialog.showModalDialog(options);
      
   


            }
        }
    }
}

Tuesday, May 8, 2012

Download selected file using ECMA

function downloadFile() {

var clientContext= SP.ClientContext.get_current();

var currentlibid = SP.ListOperation.Selection.getSelectedList();


if(currentlibid==null){
alert('Please select at least one item and try again.');
window.location.href = window.location.href;
}
else
{
var oList = clientContext.get_web().get_lists().getById(currentlibid);
var selectedItems = SP.ListOperation.Selection.getSelectedItems(clientContext);

if(selectedItems==''){
alert('Please select at least one item and try again.');
window.location.href = window.location.href;
}
else if(selectedItems.length>1){
alert('Please select only one item and try again.');
}
else{
  

    for(var i in selectedItems){

    this.oListItem = oList.getItemById(selectedItems[i].id);
    clientContext.load(this.oListItem);

    var File = this.oListItem.get_file();

clientContext.load(File);

 
clientContext.executeQueryAsync
(
function (sender, args) {
if(File != null) {

var urlValue=File.get_serverRelativeUrl();

STSNavigate('/_layouts/download.aspx?SourceUrl=' + urlValue);

clientContext.executeQueryAsync(
function (sender, args) {
 
 
},
function (sender, args) {
 
});
}
},
function (sender, args) {
  alert('You cannot download a folder. Please select a file and try again.');
 
}
);
 
    
}
}
}
}

Get list items using ECMA script

<script type="text/javascript">
    ExecuteOrDelayUntilScriptLoaded(retrieveMarketingPromotions, "sp.js");
    function retrieveMarketingPromotions() {

        var clientContext = SP.ClientContext.get_current();
        var oList = clientContext.get_web().get_lists().getByTitle('Marketing Promotions');

        var camlQuery = new SP.CamlQuery();
        camlQuery.set_viewXml('<View><Query><OrderBy><FieldRef Name="Modified" Ascending="False" /></OrderBy></Query><RowLimit>4</RowLimit></View>');
        this.collListItem = oList.getItems(camlQuery);
        clientContext.load(collListItem, 'Include(Title, FileRef, ID,Modified)');
        clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceededMP), Function.createDelegate(this, this.onQueryFailedMP));
    }
    function onQuerySucceededMP(sender, args) {

        var listItemEnumerator = collListItem.getEnumerator();

        while (listItemEnumerator.moveNext()) {
            var oListItem = listItemEnumerator.get_current();
            var dispTitle = oListItem.get_item("Title");
            var dispUrl = oListItem.get_item("FileRef");
            var dispLI = document.createElement("li");
            var dispA = document.createElement("a");
            dispA.setAttribute("href", dispUrl);
            dispA.setAttribute("id", dispTitle);
            dispA.innerHTML = dispTitle;
            dispLI.appendChild(dispA);
            document.getElementById("lstMarketing").appendChild(dispLI);
        }
        DisplayCount();
    }

    function onQueryFailedMP(sender, args) {

        alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
    }
</script>

<div id="WebpartGreyBgColor">
  <div class="MarketingImage">
    <img class="image" src="/Style%20Library/Images/img_marketing.jpg" title="Marketing"/>
  </div>
  <div class="MarketingContent">
    <ul id="lstMarketing">
    </ul>
  </div>
  <div class="breakspacer">&nbsp;</div>
  <div class="viewall">
    <p>
    <a href="/Lists/MarketingPromotions/AllItems.aspx">View All</a></p>
  </div>
</div>

Display content from rich text box using Xslt template

usage:

<xsl:call-template name="GetBodyNoTags">
                    <xsl:with-param name="origMsg" select="@Description" ></xsl:with-param>
                    <xsl:with-param name="bodyLength" select="100"></xsl:with-param>
                </xsl:call-template>

Implementation:

<xsl:template name="GetBodyNoTags">
      <xsl:param name="origMsg" />
      <xsl:param name="bodyLength" />
    <xsl:choose>
        <xsl:when test="contains($origMsg, '&lt;')">
            <xsl:variable name="test" select="concat(substring-before($origMsg, '&lt;'), substring-after($origMsg, '&gt;'))"></xsl:variable>
            <xsl:call-template name="GetBodyNoTags">
                <xsl:with-param name="origMsg" select="$test"></xsl:with-param>
                <xsl:with-param name="bodyLength" select="$bodyLength"></xsl:with-param>
            </xsl:call-template>
        </xsl:when>
          <xsl:otherwise>
            <xsl:choose>
                <xsl:when test="string-length($origMsg) &gt; $bodyLength">
                    <xsl:value-of select="concat(substring($origMsg, 0, $bodyLength), '...')" disable-output-escaping="yes"></xsl:value-of>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:value-of select="$origMsg" disable-output-escaping="yes"></xsl:value-of>
                </xsl:otherwise>
            </xsl:choose>                                  
        </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

Video rotator web part

<div>
  <div id="MediaPlayerHost"></div>
  <table  cellpadding="0" cellspacing="0" border="0" style="background-color:#D7D7D7; height:47px; width:362px">
    <tr>
      <td>
        <div id='videospacing' class="videospacing">
          <div id='items' class='items'></div>
        </div>
      </td>
    </tr>
    <tr>
      <td>
        <div class="videopagination">
          <nobr id="pag">1-3</nobr>
        </div>
        <div  class="videonextpre">
          <a id='prev' onclick='javascript:move_prev()' class="left" disabled=disabled></a>
          <a id='next' onclick='javascript:move_next()' class="right"></a>
        </div>
      </td>
    </tr>
  </table>
<script type="text/javascript" src="_layouts/mediaplayer.js"></script>
<script type="text/javascript">
    var idCount = 0, modified = 0, prev = 0, modifiedFirst = 0, idCountFirst = 0, counter = 0, itemCount = 0, pageCount = 4, click = null, count = 0, nextCount = 0; prevCount = 4;

    function move_next() {
        prev = 0;
        counter = 0;
        click = 'next';
        var curCounter = 0;

        jQuery("div[class='items']").find("a").each(function () {
            jQuery(this).remove();
        });


        retrieveListItems();
        document.getElementById('prev').disabled = false;
        document.getElementById('prev').style.cursor = "pointer";
        document.getElementById('prev').className = 'left';
        if (counter == 5) {
            document.getElementById('next').disabled = false;
            document.getElementById('next').style.cursor = "pointer";
            document.getElementById('next').className = 'right';
        }
        else {
            document.getElementById('next').disabled = true;
            document.getElementById('next').style.cursor = "text";
            document.getElementById('next').className = 'rightdim';
            // document.getElementById('next').Attributes.Add('onMouseOver', "this.style.cursor='text'");
        }
        setTimeout('displayPageCount()', 500);

        //            curCounter = jQuery("div[class='items']").find("a").length;
        //           
        //            pageCount = pageCount + curCounter;
        //            if (curCounter == 0) {
        //                document.getElementById("pag").innerHTML = pageCount + ' of ' + itemCount;
        //            }
        //            else {
        //                alert(curCounter);
        //                document.getElementById("pag").innerHTML = (pageCount - curCounter + 1) + '-' + pageCount + ' of ' + itemCount;
        //            }

    }

    function displayPageCount() {
        curCounter = jQuery("div[class='items']").find("a").length;

        pageCount = pageCount + curCounter;
        if (curCounter == 1) {
            nextCount = prevCount + 1;
            document.getElementById("pag").innerHTML = (prevCount + 1) + ' of ' + itemCount;
        }
        else {
            nextCount = prevCount + 1;
            document.getElementById("pag").innerHTML = (prevCount + 1) + '-' + (prevCount + curCounter) + ' of ' + itemCount;
        }
    }

    function displayPrevPageCount() {
        curCounter = jQuery("div[class='items']").find("a").length;
        // alert(curCounter);
        document.getElementById("pag").innerHTML = (nextCount - 4) + '-' + (nextCount - 1) + ' of ' + itemCount;
    }

    function move_prev() {
        prev = 1;
        counter = 0;
        click = 'prev';
        var curCounter = 0;
        jQuery("div[class='items']").find("a").each(function () {
            jQuery(this).remove();
        });
        retrieveListItems();
        document.getElementById('next').disabled = false;
        document.getElementById('next').style.cursor = "pointer";
        document.getElementById('next').className = 'right';

        // curCounter = jQuery("div[class='items']").find("a").length;
        pageCount = pageCount - curCounter;
        if ((nextCount - 4) == 1) {
            document.getElementById('prev').disabled = true;
            document.getElementById('prev').style.cursor = "text";
            document.getElementById('prev').className = 'leftdim';
        }
        else {
            document.getElementById('prev').disabled = false;
            document.getElementById('prev').style.cursor = "pointer";
            document.getElementById('prev').className = 'left';
        }
        prevCount = nextCount - 1;
        document.getElementById("pag").innerHTML = (nextCount - 4) + '-' + (nextCount - 1) + ' of ' + itemCount;
        // setTimeout('displayPrevPageCount()', 1000);
        //document.getElementById("pag").innerHTML = (pageCount - 3) + '-' + pageCount + ' of ' + itemCount;

    }

    function scroll() {
        $('.items').cycle({
            fx: 'cover',
            speed: 500,
            timeout: 2000
        });
    }

    function getMediaPlayer() {
        var p = document.getElementById("MediaPlayerHost")
        var obj = p.getElementsByTagName("object");
        return obj[0].Content.MediaPlayer;
    }

    function SetMediaSource(imgObj) {
        //alert(imgObj.id);
        jQuery("div[class='items']").find("img").each(function () {
            jQuery(this).attr("class", "photo");
        });
        var imagTga = document.getElementById(imgObj.id);
        if (imagTga != undefined) {
            document.getElementById(imgObj.id).setAttribute("class", "videoselected");
        }
        var p = getMediaPlayer();
        var clickArgs = imgObj.tag.split(";");
        p.MediaSource = clickArgs[0];
        p.PreviewImageSource = clickArgs[1];
        p.AutoPlay = true;
        p.Play();
    }

    function SetMediaSourceImage(imgObj) {
        var p = getMediaPlayer();
        var clickArgs = imgObj.tag.split(";");
        p.PreviewImageSource = clickArgs[1];
        p.AutoPlay = false;
    }


    function DisplayCount() {

        var clientContext = SP.ClientContext.get_current();
        var oList = clientContext.get_web().get_lists().getByTitle('Videos');
        var camlQuery = new SP.CamlQuery();
        camlQuery.set_viewXml('<View><RowLimit></RowLimit></View>');
        this.listItems = oList.getItems(camlQuery);
        clientContext.load(listItems);
        clientContext.executeQueryAsync(
                     Function.createDelegate(this, this.onListItemsLoadSuccess),
                     Function.createDelegate(this, this.onQueryFailed));
        retrieveListItems();
    }

    function onListItemsLoadSuccess(sender, args) {
        var listEnumerator = this.listItems.getEnumerator();
        while (listEnumerator.moveNext()) {
            itemCount++;
        }
        //alert(itemCount);
        document.getElementById("pag").innerHTML = (pageCount - 3) + '-' + pageCount + ' of ' + itemCount;
        if (itemCount == 4) {
            document.getElementById('next').disabled = true;
            document.getElementById('next').style.cursor = "text";
            document.getElementById('next').className = 'rightdim';
        }
        document.getElementById('prev').style.cursor = "text";
        document.getElementById('prev').className='leftdim';
    }

 

    function retrieveListItems() {

        var clientContext = SP.ClientContext.get_current();
        var oList = clientContext.get_web().get_lists().getByTitle('Videos');

        var camlQuery = new SP.CamlQuery();
        if (idCount == 0 && modified == 0) {
            camlQuery.set_viewXml('<View><Query><OrderBy><FieldRef Name="Modified" Ascending="False" /></OrderBy></Query><RowLimit>4</RowLimit></View>');
        }
        else {
            if (prev == 0) {
                var d = Date.parse(modified);
                var mon = new Date(d);
                // 2012-04-18T21:48:39Z
                var fDate = mon.getYear() + '-' + (mon.getMonth() + 1) + '-' + mon.getDate() + 'T' + mon.getHours() + ':' + mon.getMinutes() + ':' + mon.getSeconds() + 'Z';

                camlQuery.set_viewXml('<View><Query><Where><And><Leq><FieldRef Name="Modified" /> ' +
                                  '<Value IncludeTimeValue="TRUE" Type="DateTime">' + fDate + '</Value></Leq><Neq>' +
                                  '<FieldRef Name="ID" /><Value Type="Counter">' + idCount + '</Value></Neq></And></Where><OrderBy>' +
                                  '<FieldRef Name="Modified" Ascending="False" /></OrderBy></Query><RowLimit>5</RowLimit></View>');
            }
            else if (prev == 1) {
                var d = Date.parse(modifiedFirst);
                var mon = new Date(d);
                // 2012-04-18T21:48:39Z
                var fDate = mon.getYear() + '-' + (mon.getMonth() + 1) + '-' + mon.getDate() + 'T' + mon.getHours() + ':' + mon.getMinutes() + ':' + mon.getSeconds() + 'Z';

                camlQuery.set_viewXml('<View><Query><Where><And><Geq><FieldRef Name="Modified" /> ' +
                                  '<Value IncludeTimeValue="TRUE" Type="DateTime">' + fDate + '</Value></Geq><Neq>' +
                                  '<FieldRef Name="ID" /><Value Type="Counter">' + idCountFirst + '</Value></Neq></And></Where><OrderBy>' +
                                  '<FieldRef Name="Modified" Ascending="False" /></OrderBy></Query><RowLimit>5</RowLimit></View>');
            }
        }
        this.collListItem = oList.getItems(camlQuery);

        clientContext.load(collListItem, 'Include(Title, FileRef, ID,Modified,AlternateThumbnailUrl,_Comments)');

        clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));

    }


     //SP.SOD.executeOrDelayUntilScriptLoaded(DisplayCount, 'SP.js');

    function onQuerySucceeded(sender, args) {

        var listItemEnumerator = collListItem.getEnumerator();

        while (listItemEnumerator.moveNext()) {

            var oListItem = listItemEnumerator.get_current();
            //alert(oListItem.get_item("AlternateThumbnailUrl").get_url());
            var previewImgUrl = null;
            var ImgTitle = null;
            var ImgDesc = null;
            if (oListItem.get_item("AlternateThumbnailUrl") != null) {
                previewImgUrl = oListItem.get_item("AlternateThumbnailUrl").get_url();
            }
            if (previewImgUrl == null) {
                previewImgUrl = "/_layouts/images/VideoPreview.png";
            }

            if (oListItem.get_item("Title") != null) {
                ImgTitle = oListItem.get_item("Title");
            }
            else {
                ImgTitle = "";
            }


            mediaPlayer.createMediaPlayer(
          document.getElementById('MediaPlayerHost'),
          'MediaPlayerHost',
          '362px', '179px',
          {
              displayMode: 'Inline',
              mediaTitle: '',
              mediaSource: oListItem.get_item('FileRef'),
              previewImageSource: previewImgUrl,
              autoPlay: false,
              loop: false,
              mediaFileExtensions: 'wmv;wma;avi;mpg;mp3;',
              silverlightMediaExtensions: 'wmv;wma;mp3;'
          });
            idCountFirst = oListItem.get_item("ID");
            modifiedFirst = oListItem.get_item("Modified");
            var imageID = 'image' + count;
            var imgHost = document.getElementById('items');
            var aTag = document.createElement('a');
            aTag.setAttribute('title', ImgTitle);
            var newimg = document.createElement('img');
            newimg.setAttribute('src', previewImgUrl);
            newimg.setAttribute('height', '44px');
            newimg.setAttribute('width', '78px');
            newimg.setAttribute('class', 'photo');
            newimg.setAttribute('id', imageID);
            newimg.setAttribute('tag', oListItem.get_item('FileRef') + ";" + previewImgUrl);
            newimg.setAttribute('onmouseover', "javascript:SetMediaSourceImage(this)");
            newimg.setAttribute('onclick', "javascript:SetMediaSource(this)");
            aTag.appendChild(newimg);
            imgHost.appendChild(aTag);
            count++;
            counter++;
            break;
        }

        while (listItemEnumerator.moveNext()) {
            var oListItem = listItemEnumerator.get_current();
            //var previewImgUrl = oListItem.get_item("AlternateThumbnailUrl");
            var previewImgUrl = null;
            var ImgTitle = null;
            var ImgDesc = null;
            if (oListItem.get_item("AlternateThumbnailUrl") != null) {
                previewImgUrl = oListItem.get_item("AlternateThumbnailUrl").get_url();
            }
            if (previewImgUrl == null) {
                previewImgUrl = "/_layouts/images/VideoPreview.png";
            }

            if (oListItem.get_item("Title") != null) {
                ImgTitle = oListItem.get_item("Title");
            }
            else {
                ImgTitle = "";
            }


            idCount = oListItem.get_item("ID");
            modified = oListItem.get_item("Modified");
            var imgHost = document.getElementById('items');
            var imageID = 'image' + count;
            var aTag = document.createElement('a');
            aTag.setAttribute('title', ImgTitle);
            var newimg = document.createElement('img');
            newimg.setAttribute('src', previewImgUrl);
            newimg.setAttribute('height', '44px');
            newimg.setAttribute('width', '78px');
            newimg.setAttribute('class', 'photo');
            newimg.setAttribute('alt', ImgTitle);
            //newimg, setAttribute('title', ImgTitle);
            newimg.setAttribute('id', imageID);
            newimg.setAttribute('tag', oListItem.get_item('FileRef') + ";" + previewImgUrl);
            newimg.setAttribute('onmouseover', "javascript:SetMediaSourceImage(this)");
            newimg.setAttribute('onclick', "javascript:SetMediaSource(this)");
            aTag.appendChild(newimg);
            imgHost.appendChild(aTag);
            count++;
            counter++;
        }
        if (click == null) {
            document.getElementById("pag").innerHTML = (pageCount - 3) + '-' + pageCount + ' of ' + itemCount;
        }

        //        if (counter != 4) {
        //            document.getElementById('next').disabled = true;
        //        }
    }

    function onQueryFailed(sender, args) {

        alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
    }

</script>

Tuesday, January 24, 2012

More... link in Content Query Webpart

Following requirements achieved  using content query web part with combination for XSL style sheet
1. More link to navigate all items
2. Add New item link to add new item and should open in a dialog window
3. Each item has to be hyperlinked and should open in a dialog window
Snapshot of final output
clip_image001

Implementation Details
Achieved by creating custom XSL template, and associated to Content Query web part
We can reuse this template with minor changes. Hope this template will save your time while implementing these kind of solutions
<xsl:template name="moreArticles" match="Row[@Style='moreArticles']" mode="itemstyle">
<xsl:variable name="SafeLinkUrl">
<xsl:call-template name="OuterTemplate.GetSafeLink">
<xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="SafeImageUrl">
<xsl:call-template name="OuterTemplate.GetSafeStaticUrl">
<xsl:with-param name="UrlColumnName" select="'ImageUrl'"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="DisplayTitle">
<xsl:call-template name="OuterTemplate.GetTitle">
<xsl:with-param name="Title" select="@Title"/>
<xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="LinkTarget">
<xsl:if test="@OpenInNewWindow = 'True'" >_blank</xsl:if>
</xsl:variable>
<div id="linkitem" class="item">
<xsl:if test="string-length($SafeImageUrl) != 0">
<div class="image-area-left">
<a href="{$SafeLinkUrl}" target="{$LinkTarget}">
<img class="image" src="{$SafeImageUrl}" alt="{@ImageUrlAltText}" />
</a>
</div>
</xsl:if>
<div class="item bullet link-item">
<xsl:call-template name="OuterTemplate.CallPresenceStatusIconTemplate"/>
<!—following line of code for open item in dialog window-->
<a href="/departments/it/KnowledgeBase/_layouts/listform.aspx?PageType=4&amp;ListId={@ListId}&amp;ID={@ID}" onclick="EditLink2(this,ctx.ctxId);return false;" onfocus="OnLink(this)" target="_self">
<!--<a href="{$SafeLinkUrl}" target="{$LinkTarget}" title="{@LinkToolTip}">-->
<xsl:value-of select="$DisplayTitle"/>
</a>
<div class="description">
<xsl:value-of select="substring(@Description,1,200)" disable-output-escaping="yes" />
</div>
</div>
</div>
<xsl:if test="count(following-sibling::*)=0">
<div>
<!—following line of code for more link-->
<p align="right"><strong><a><xsl:attribute name="href">/departments/it/knowledgebase/pages/MoreArticles.aspx</xsl:attribute>More KB Articles...</a></strong></p>
<!—following line of code for Add New Item link-->
<p align="left"><img src="/PublishingImages/kbImages/addImg.png" alt=""/><strong><a><xsl:attribute name="onclick">javascript:NewItem2(event, &quot;/departments/it/knowledgebase/_layouts/listform.aspx?PageType=8&amp;ListId={8386e5d5-f918-4c9c-9e70-c39943dcbc70}&amp;RootFolder=&quot;);javascript:return false;</xsl:attribute> <xsl:attribute name="href">/departments/it/knowledgebase/_layouts/listform.aspx?PageType=8&amp;ListId={8386e5d5-f918-4c9c-9e70-c39943dcbc70}&amp;RootFolder=</xsl:attribute>Add New KB Article</a></strong></p>
</div>
</xsl:if>
</xsl:template>

Custom Site map provider


SharePoint provides global navigation display multiple level of navigation with some limitations

Scenario:
clip_image001
In the above screen Corporate is sub site. And IT, HR, Admin and Corporate Matter are the document libraries. We need one more level of menu with folders of each library.
We can’t achieve this scenario by increasing the StaticDisplayLevels to 2 in the Global navigation menu in the master page.
We take custom site map provider approach to achieve the functionality
1. Create notepad file and name it as CustomSiteMap.sitemap
2. Open the document create nodes like :
<?xml version="1.0" encoding="utf-8" ?>
<siteMap>
<siteMapNode title="" url="">
<siteMapNode title="Corporate" url="/Pages/Corporate.aspx">
<siteMapNode title="IT" url="/Lists/IT/AllItems.aspx">
<siteMapNode title="Hydra" url="/Lists/HR/AllItems.aspx"/>
</siteMapNode>
<siteMapNode title="HR" url="/Lists/HR/AllItems.aspx"/>
<siteMapNode title="Admin" url="/Lists/admin/AllItems.aspx"/>
<siteMapNode title="Corporate Matters" url="/Lists/cormatter/AllItems.aspx"/>
</siteMapNode>
</siteMapNode>
</siteMap>

3. Save the file in 14hive/_Layouts/<CustomSiteProvider>/
4. Open targeted applications’ web.config file find for <providers> tag
5. Make this entry : <add name="CustomGlobalNavSiteMapProvider" siteMapFile="/_layouts/ CustomSiteProvider / CustomSiteMap.sitemap" type="System.Web.XmlSiteMapProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
6. Save and close the web.config
7. Open targeted application master page in SP designer
8. Try to simulate following snippet
<SharePoint:AspMenu
ID="TopNavigationMenuV4"
Runat="server"
EnableViewState="false"
DataSourceID="topSiteMap"
AccessKey="<%$Resources:wss,navigation_accesskey%>"
UseSimpleRendering="true"
UseSeparateCss="false"
Orientation="Horizontal"
StaticDisplayLevels="1"
MaximumDynamicDisplayLevels="3"
SkipLinkText=""
CssClass="s4-tn" Width="1024px">
</SharePoint:AspMenu>
<SharePoint:DelegateControl runat="server" ControlId="CustomXmlContentMapProvide" Id="topNavigationDelegate">
<Template_Controls>
<asp:SiteMapDataSource
ShowStartingNode="False"
SiteMapProvider="CustomGlobalNavSiteMapProvider"
id="topSiteMap"
runat="server"/>
</Template_Controls>
</SharePoint:DelegateControl>

9. Publish the master page.
10. Browse the application, and we can see custom global navigation

Sunday, October 23, 2011

Announcement Summary View

To make announcement data in summary view

1. Append following additional ParameterBinding tabs

<ParameterBinding Name="AddNewAnnouncement" Location="Resource(wss,idHomePageNewAnnounce)" />
                            <ParameterBinding Name="MoreAnnouncements" Location="Resource(wss,MoreAnnouncements)" />
                            <ParameterBinding Name="ByText" Location="Resource(wss,2000)" />

2. Update BaseViewID=0

3. Replace entire viewFields with following tags

<FieldRef Name="LinkTitleNoMenu" Explicit="TRUE"/>
                                    <FieldRef Name="Body" Explicit="TRUE"/>
                                    <FieldRef Name="Author" Explicit="TRUE"/>
                                    <FieldRef Name="Modified" Explicit="TRUE"/>
                                    <FieldRef Name="Attachments" Explicit="TRUE"/>

Tuesday, September 6, 2011

SP2010 installation on windows7

Failed to start the database service MSSQL$OfficeServers

Go to “regedit”, browse thru “HKLM_Local_Machine/Software/Microsoft/Shared Tools/Web Server Extensions/12.0/WSS/”. Then change the value of attribute named “ServerRole” from SINGLESERVER to APPLICATION.

Tuesday, May 10, 2011

Planning for Internet Presence Site



Internet facing site scenario

Stages:

1.      Evaluate business problems and choose MOSS

2.      Plan the site

3.      Plan how the site will be maintained

4.      Plan and deploy underlying infrastructure

5.      Build the site and deploy

6.      Configure operations

7.      Maintain and modify the site

8.      Maintain infrastructure

Scenario Data

Business Needs


Authenticated Users

Developers -1, Tester -1, Authors – 10 authors and editors, 3-5 web
designers and graphic artists

Corpus Size

Anticipate corpus size

Document sizes and amount of changes

Average document size: 10 KBNumber of
documents published per publishing cycle: 20 average, up to 45
Percentage increase in number of documents
expected over three years: 5% per year

Visits per day

Average 1.5 million per day

Peak : 2.5 million per day

Days of peak usage : Quarterly and year end closing announcements

Performance

Acceptable time for first page load for local area users on broadband
connection :2 sec




Server farm
topologies


Integration farm

Single farm / Virtual server

Authoring farm

2 front end web servers and Cluster DB server

Production farm
(failover farm identical)

3 front end web servers, 1 serving queries, 1 application server,
Clustered DB servers



Hardware and Software


Authoring Farm

Clustered DB servers

4 3 GHz or faster processors16 GB RAM
minimum recommended
15 GB hard drive
(holds corpus: 1,000,000 10 KB documents)
Windows Server 2003 R2 Enterprise x64
EditionSQL Server 2005 Enterprise Edition

Front End Servers

Dual 3 GHz or faster processors4 GB RAM minimum recommendedAvailable disk space to hold the index of at
least .34 * the size of the corpus, plus room for the binary large object
(BLOB)
cache — approximately 20 MB.
Windows
Server 2003 R2 Enterprise x64 Editio
n

Production farm
(Failover farm identical )

Clustered DB servers

4 3 GHz or faster processors16 GB RAM15 GB hard drive (holds corpus: 1,000,000 10 KB
documents)
Windows Server
2003 R2 Enterprise x64 Edition
SQL
Server 2005 Enterprise Edition

Front End Servers

Dual 3 GHz or faster processors4 GB RAM Available
disk space to hold the index of at least .34 * the
size of the corpus,
plus room for the BLOB cache — approximately 20 MB.
Windows Server 2003 R2 Enterprise x64 Edition

Index server

Dual 3 GHz or faster processors4 GB RAM Available disk space to hold the index of at
least .34 * the size of the corpus

Integration Farm

Single server. 4 3 GHz or
faster processors16 GB RAM500 GB disk spaceWindows Server 2003 R2 Enterprise x64 EditionSQL Server 2005 Developer EditionVisual Studio 2005 Team Edition for
Developers







Scenario Roles


Role

Team

Definition

Solution Architect

Solutions

Leads in the specifications of solution’s design and implementation

Program Manger

Solutions

Writes the solution’s specifications and helps manage the solution
creation and deployment process

Program Manager

Core IT

Writes the infrastructure related to hosting the site and helps
implement and test the infrastructure

Content Manger

Solutions

Responsible for the site’s content and Signs off on major content
decisions

Designer

Solutions

Responsible for designing and creating site artifacts (Master Pages,
Style sheets and graphics)

Developer

Solutions

Responsible for developing software customizations

Tester

Solutions

Responsible for testing software customizations , also responsible verifying
the content in staging environment

Service Manager

Core IT

Manages all Sharepoint IT services, responsible for service supporting
the internet presence site

IT Administrator

Core IT

Responsible for centrally administrating sharepoint
services, including new service supporting for internet presence site

IT Operator

Core IT

Responsible for operations related to site such as backing up and
restoring site and managing content deployment jobs reports

Author

Solutions

Authors content for site

Editor

Solutions

Edits content and approves publication

Business Decision Maker

Marketing

Senior manager ultimately responsible for success of the internet
processing site; sponsors the entire project