Wednesday, February 15, 2012

Dynamically Change the CSS for MOSS 2007 Master Page.

1.Crate more than two CSS file with different color code.
2. Upload the css files into the any of the document library. In this put in "Shared Documents".
3.Created eight CSS file and upload in the "Shared Documents".
4.Go the sharepoint Designer 2007.
5.Open site collection.
6.Go the master page under the catalogs folder.
7.Copy the default.master and paste rename into "Custom.master".
8.In the Master page <head> section add the following javascript.


<script type="text/javascript" language="javascript">

function loadjscssfile(filename, filetype){
var randomnumber=Math.floor(Math.random()*8);
// alert(randomnumber);
MyNumbers=new Array
("Customtest_green.css","Customtest_red.css","Customtest_orange.css","Customtest_pink.css","Customtest_purple.css","Customtest_turquoise.css","Customtest_yellow.css","Customtest.css");
filename="http://192.168.1.201/sites/test/Shared%20Documents/"+MyNumbers[randomnumber].toString();
  if (filetype=="css"){ //if filename is an external CSS file
  var fileref=document.createElement("link")
  fileref.setAttribute("rel", "stylesheet")
  fileref.setAttribute("type", "text/css")
  fileref.setAttribute("href", filename)
 }
 if (typeof fileref!="undefined")
  document.getElementsByTagName("head")[0].appendChild(fileref)
}


loadjscssfile("http://192.168.1.201/sites/test/Shared%20Documents/Customtest_green.css", "css") ////dynamically load and add this .css file
</script>

9.Save and publish the master page.
10. Now while loading the page randomly took the css.


Wednesday, February 1, 2012

Expand and Collapse the SharePoint Web parts.

1. Click on the Edit page Under "Site Actions".
2.Add Content Editor Web part any Zone.
3.Click on the Web part. "Click here to add content"
4.Click On "Edit Html Source" on the Ribbon.
5.Add following code.


<script type="text/javascript">
// Add the Web Part Titles here to have them opened by default
var wpsToSkip = ['Search Documents','sandbox'];
 //Add multiple Web parts to skip the Collapse
//var wpsToSkip = ['Search Documents','Pending Documents','sandbox'];


function wpExpander() {
 var theTDs = document.getElementsByTagName("TD");
 for (var t=0;t<theTDs.length;t++) {
  var id = theTDs[t].id;
  if (id.match("WebPartTitleWPQ")) {
   id = id.substr(id.indexOf("WPQ"));
   var title = (theTDs[t].innerText || theTDs[t].textContent).replace(/[\n\r]/,'');
   var strImg = "<img style='margin:6px 5px 0px 2px;cursor:hand;float:left;' ";
   if (wpsToSkip.join().match(title)) {
    strImg += "onClick='showHide(\""+id+"\",this)' src='/_layouts/images/minus.gif'>";
   } else {
    strImg += "onClick='showHide(\""+id+"\",this)' src='/_layouts/images/plus.gif'>";
    document.getElementById("WebPart"+id).style.display = "none";
   }
   theTDs[t].innerHTML = strImg + theTDs[t].innerHTML;
  }
 }
}


function showHide(i,o) {
 var wp = document.getElementById("WebPart"+i);
 wp.style.display = (wp.style.display=="") ? "none" : "";
 o.src = (o.src.match(/plus.gif/)) ? "/_layouts/images/minus.gif" : "/_layouts/images/plus.gif";
}


_spBodyOnLoadFunctionNames.push("wpExpander()");
</script>


6.Make this Web part as Hidden.
7.Save and Close the web part.



Sunday, January 29, 2012

Add Bullet to SharePoint Quick Launch

Add the core.css classes in your Custom CSS.
Find the Following CSS and add below code.


.s4-ql ul.root ul{
list-style-type: square !important; (OR)
list-style:none inside url('/sites/cppolicy/Style%20Library/Images/img-icon-leftnav.png');
   list-style-position: outside !important;
     margin-left: 25px !important;
}

.s4-ql ul.root ul > li > a{
/* Display Bullet in Quick Launch*/
      display: inline-block !important;
     padding-bottom: 0px !important;
     padding-left: 0px !important;
     vertical-align:bottom !important;
}

Friday, January 20, 2012

SharePoint Top navigation links read from the External file.


Get data from external file for SharePoint Top Navigation:
1.      Open the Web.config file for the SharePoint web application with a text editor such as notepad.
2.      Take copy the web.config before modifying the file.
3.      Path of the web.config is “C:\inetpub\wwwroot\wss\VirtualDirectories\80\”
4.      Add the following code in the siteMap and providers  as a last row.
<siteMap defaultProvider="CurrentNavigation" enabled="true">
      <providers>
<add name="CustomNavigationProvider" siteMapFile="/_layouts/1033/styles/CustomNavigationProvider/CustomSiteMap.sitemap" type="System.Web.XmlSiteMapProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />

5.      Save the Web.config and close it.
6.      Create a SiteMap file named CustomSiteMap.sitemap and put it into a new folder with the name CustomNavigationProvider. Add this folder into following directory: \14\TEMPLATE\LAYOUTS\1033\STYLES\CustomNavigationProvider

<?xml version="1.0" encoding="utf-8" ?>
<siteMap>
 
  <siteMapNode title="" url="">
    <siteMapNode title="Home" url="/"/>
    <siteMapNode title="sitecollection1" url="/sites/sitecollection1"> </siteMapNode>
   
  <siteMapNode title="Functions">
                  <siteMapNode title="sitecollection2" url=" /sites/sitecollection1 "/>
                  <siteMapNode title=" sitecollection3" url=" /sites/sitecollection3"/>
                  <siteMapNode title="ISC" url="/sites/isc"/>
                  <siteMapNode title="IT" url="/sites/it"/>
  </siteMapNode>
 </siteMapNode>
</siteMap>

7.      Open the master page and search for the content placeholder with the id PlaceHolderHorizontalNav. Replace this placeholder with this code:

<SharePoint:AspMenu
      ID="TopNavigationMenuV4"
      Runat="server"
      EnableViewState="false"
      DataSourceID="topSiteMap"
      AccessKey="<%$Resources:wss,navigation_accesskey%>"
      UseSimpleRendering="true"
      UseSeparateCss="false"
      Orientation="Horizontal"
      StaticDisplayLevels="2"
      MaximumDynamicDisplayLevels="1"
      SkipLinkText=""
      CssClass="s4-tn"
      Visible="false"/>
    <SharePoint:DelegateControl runat="server" ControlId="TopNavigationDataSource" Id="topNavigationDelegate"><Template_Controls>
            <asp:SiteMapDataSource
              ShowStartingNode="False"
              SiteMapProvider="SPNavigationProvider"
              id="topSiteMap"
              runat="server"
              StartingNodeUrl="sid:1002"/>
        </Template_Controls></SharePoint:DelegateControl>
       
       
        <SharePoint:AspMenu
      ID="CustomXmlNavigationAspMenu"
      Runat="server"
      EnableViewState="false"
      DataSourceID="CustomNavigationSiteMapDataSource"
      AccessKey="<%$Resources:wss,navigation_accesskey%>"
      UseSimpleRendering="true"
      UseSeparateCss="false"
      Orientation="Horizontal"
      StaticDisplayLevels="1"
      MaximumDynamicDisplayLevels="3"
      SkipLinkText=""
      CssClass="s4-tn">
   
    </SharePoint:AspMenu>

    <!-- Second sitemap DS -->
    <SharePoint:DelegateControl runat="server" ControlId="CustomXmlMapProviderDelegateControl">
        <Template_Controls>    
            <asp:SiteMapDataSource
              ShowStartingNode="False"
              SiteMapProvider="CustomNavigationProvider"
              id="CustomNavigationSiteMapDataSource"
              runat="server" />
        </Template_Controls>
    </SharePoint:DelegateControl>

8.      Save the master page now the Top navigation read the external file. If you want add new link to the top navigation add it into the CustomSiteMap.sitemap.




Friday, December 16, 2011

Converting a Custom SharePoint 2010 Master Page into a Search Center Master Page


  1. Make a copy of v4.master (or whatever other custom master page you are working with) and give it a new name like v4_searchcenter.master.
  2. Edit the new master page and locate and remove the PlaceHolderTitleBreadcrumb. This will allow the pop-out breadcrumb to still function properly:
    <asp:ContentPlaceHolder id="PlaceHolderTitleBreadcrumb" runat="server">
    <SharePoint:ListSiteMapPath
    runat="server"
    SiteMapProviders="SPSiteMapProvider,SPContentMapProvider"
    RenderCurrentNodeAsLink="false"
    PathSeparator=""
    CssClass="s4-breadcrumb"
    NodeStyle-CssClass="s4-breadcrumbNode"
    CurrentNodeStyle-CssClass="s4-breadcrumbCurrentNode"
    RootNodeStyle-CssClass="s4-breadcrumbRootNode"
    NodeImageOffsetX=0
    NodeImageOffsetY=353
    NodeImageWidth=16
    NodeImageHeight=16
    NodeImageUrl="/_layouts/images/fgimg.png"
    RTLNodeImageOffsetX=0
    RTLNodeImageOffsetY=376
    RTLNodeImageWidth=16
    RTLNodeImageHeight=16
    RTLNodeImageUrl="/_layouts/images/fgimg.png"
    HideInteriorRootNodes="true"
    SkipLinkText="" />
    </asp:ContentPlaceHolder>
  3. Next, add the PlaceHolderTitleBreadcrumb back right before the PlaceHolderMain. This will allow the search center to inject the search box in a good location:
    <asp:ContentPlaceHolder id="PlaceHolderTitleBreadcrumb" runat="server"></asp:ContentPlaceHolder>
    <asp:ContentPlaceHolder id="PlaceHolderMain" runat="server"/>
  4. Move PlaceHolderPageTitleInTitleArea (and any supporting HTML) to a hidden panel because this placeholder isn’t used the same way in the search center:
    <asp:ContentPlaceHolder id="PlaceHolderPageTitleInTitleArea" runat="server" />
    <asp:Panel visible="false" runat="server">
    <asp:ContentPlaceHolder id="PlaceHolderPageTitleInTitleArea" runat="server" />
    </asp:Panel>
  5. For v4.master you will also want to remove ClusteredDirectionalSeparatorArrow and <h2></h2>. It won’t make sense to show these at the top now:
    <SharePoint:ClusteredDirectionalSeparatorArrow runat="server"/>
    <h2></h2>
  6. Next, several lines of CSS need to be added to make sure things look right for the search center. You can add them to the <head> section of the master page:
    <style type="text/css">
    /* remove left margin */
    .s4-ca {
    margin-left: 0px;
    }
    /* remove gray background at top (optional) */
    .srch-sb-results {
    background:transparent none repeat scroll 0 0;
    }
    /* clean up top padding on 1st search page */
    .srch-sb-main {
    padding-top: 20px;
    }
    /* remove centering on 1st search page (optional) */
    .srch-sb-results4 {
    margin: inherit;
    padding-left: 20px;
    }
    /* remove background color on 1st search page (useful for colored designs) */
    .ms-bodyareaframe {
    background-color: transparent;
    }
    /* ------------------------------------------ */
    /* -- CSS that may be req. to reset the search styling -- */
    /* ------------------------------------------ */
    /* fix height of area above search results */
    td.ms-titleareaframe, div.ms-titleareaframe, .ms-pagetitleareaframe {
    height: auto !important;
    }
    /* fix border color on search results */
    .ms-main .ms-ptabrx, .ms-main .ms-sctabrx, .ms-main .ms-ptabcn, .ms-main .ms-sctabcn {
    border-color: #eeeeee;
    }
    /* fix arrangement of body area on search results */
    .srch-sb-results {
    height: auto;
    }
    /* fix positioning of prefs and advanced link on results */
    .ms-sblink {
    display:block;
    }
    /* fix the color of the prefs and advanced link on results */
    .ms-sblink a:link, .ms-sblink a:visited, .ms-sblink a:hover {
    color:#0072BC;
    }
    </style>
    5. Save the new master page, and check in / publish as a major version and approve it. Apply this master page to only the search center, and apply it as site master page while leaving system master page set as v4.master.
UPDATE: Some commenters have pointed out that if you want to edit pages in the Search Center (and who doesn’t?) these changes result in a double ribbon scenario. I haven’t fully tested this fix, so I’d be curious to hear about the results, but it looks like this would fix it:
  1. Add <asp:ContentPlaceHolder id="PlaceHolderGlobalNavigation" runat="server"/> to the hidden panel.
  2. Remove <div id="s4-ribboncont">…</div> and ALL of its contents.
  3. Add in its place this line: <asp:ContentPlaceHolder ID="SPNavigation" runat="server"></asp:ContentPlaceHolder>.

screenshots of the final result:



Wednesday, November 30, 2011

Hide List Column Headers / Titles In List Web Parts


There are several methods available.
Below you can see the list with the list column headers showing.
Hide List Column Headers - Column Headers Showing

Add CSS, Javascript Or JQuery To The Page Using A Content Editor Web Part

1: Add a Content Editor Web Part (CEWP) to the page.
Hide List Column Headers - Add CEWP
Move it below the list view web part, otherwise the Javascript and JQuery won’t work, and also your list will loose the ribbon.
The code will be added to this web part.
Remember that view pages are still just web part pages, and you can edit the page.
2: Click in the web part, and in the ribbon click HTML and then Edit HTML Source.
Hide List Column Headers - Edit HTML Source
3: Add either the CSS, Javascript or JQuery snippets as seen below, depending on your preferences.
Since a Content Editor Web Part (CEWP) is added to the page, you will loose the view selection drop down using all 3 methods.

Hide List Column Headers With CSS

Add the following text to the Content Editor Web Part (CEWP).
<style>
tr.ms-viewheadertr {
display: none
}
</style>

This will work fine if it’s a view page, but in case you have added several list views to a page, then this will hide the headers of all lists.
In case you want to just hide a specific list you will have to use Javascript or JQuery. You can’t just use IDs since SharePoint has a tendency to reuse them even though that is a big no no.
With Javascript and JQuery you can iterate through the tables and find the table whose summary attribute contains the title of the list.
In the snippets below the name of the list is Hide Column Headers.

Hide List Column Headers Of A Specific List Using Javascript

The correct list table is found by first getting all table elements, and then iterate through them, and find the one(s) with the name Hide Column Headers, which is indicated by the summary attribute. The first row in the table contains the headers, so we will just hide that one.

<script>
var tables = document.getElementsByTagName("table") 
var i;
var rows;
for (i=0;i<tables.length;i++) 
{
if (tables(i).summary == "Hide Column Headers")  
{
rows = tables(i).getElementsByTagName("tr")
rows(0).style.display = "none" 
} 
}
</script>

When using this trick, you are iterating through actual HTML content, so you have to place the content editor web part after the list view web part.
Otherwise the generated html won’t be available. Same thing with JQuery.

Hide List Column Headers Of A Specific List Using JQuery

Using JQuery is definitely also an option and can be seen below. The result is the same.
It will find all tables with an attribute called summary whose value is “List Title” and then it will hide the first (0 based index) table row.
In SharePoint the first table row will always contain the header.

<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery/jquery-1.4.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("table[summary='Hide Column Headers'] tr:eq(0)").hide()
});
</script>

4: Edit the view, and uncheck Allow individual item checkboxes in the tabular view section, if you don’t want the pesky checkboxes to appear.
Save the page and reload it and you should see the result.
Hide List Column Headers - Hidden Columns

Hide List Column Headers With SharePoint Designer 2010

1: Go to list settings and click on the Edit List in SharePoint Designer button.
Hide List Column Headers - Edit Page With SPD
2: Once SPD opens up, click the view you wish to change.
Hide List Column Headers - SPD Views
3: Right-click in any of the column header cells.
Hide List Column Headers - SPD Find Column Header
4: Click Delete -> Delete Rows.
Hide List Column Headers - SPD Celete Column Headers
5: Click the save button.
Please remember that this will customize (unghost) your page, so if you can live with the missing view selector,



Wednesday, November 9, 2011

Move .wsp files from one server to another server farm

1.Copy the .wsp file from old server Visual studio project debug folder .
2.Paste the .wsp into the new sever (like "C:\backup\file.wsp").
3.Open the "SharePoint 2010 Management shell" Run as Administrator mode.
4.Use the following code.

    Deploy Event Receiver and Master page as farm solutions
     Add-SPSolution -LiteralPath "C:\backup\file.wsp"
      Install-SPSolution -Identity file.wsp –GACDeployment


    Deploy Visual Webpart:
    Add-SPSolution -LiteralPath "C:\backup\file.wsp"
     Install-SPSolution -Identity file.wsp -WebApplication http://serverurl –GACDeployment

  Deploy Sandbox solutions. 
Add-SPUserSolution -LiteralPath  C:\backup\file.wsp  -Site  http://serverurl /sites/name
Install-SPUserSolution -Identity  file.wsp  -Site http://serverurl /sites/name
 
 Note:http://serverurl ----> http://servername ex:(http://Sharepoint)

Give Read Permission for SharePoint Add-in for Azure AD Send Mail to Office 365 Domain Group users.

Below are the Steps for Send Mail to Office 365 Domain Group or AD Group users from Provider Hosted ADD-IN. For this we needs to Give Permi...