Showing posts with label SharePoint 2010. Show all posts
Showing posts with label SharePoint 2010. Show all posts

Friday, November 16, 2012

SharePoint 2010 CSS Reference Chart



SharePoint 2010 CSS Reference Chart by Heather


Thanks to Heather for her excellent post on SharePoint 2010 Branding

 

SharePoint 2010 global navigation with 3 Levels of Dynamic Menu

SharePoint 2010 global navigation with 3 Levels of Dynamic Menu Style

[image[4].png]

Adding 3 Levels of Dynamic Menu Style to SharePoint 2010 global navigation

To make the changes, follow these simple steps:

1. Open the site in SharePoint Designer

2. From the left hand navigation, choose Master pages and in then click the appropriate Master Page. In this example I selected the v4.master. When promted to checkout, choose yes.

3. Once the Master Page has loaded, select to view it in Code mode.

4. At this point you will need to search the code for the keyword "Orientation". This will bring you to the section of code where we need to make our changes.

5. At this point you can enter your values for StaticDisplayLevels and MaximumDynamicDisplay Levels.

  • StaticDisplayLevels is the number of levels of sub navigation to show by default
  •  MaximumDynamicDisplayLevels is the number of levels of sub navigation to show as flyouts when hovered over.








Happy SharePointing !!!

Friday, September 14, 2012

Download all the content of a list/document library to a file share.

Download all the content of a list/document library to a file share. This script should ensure the folder structure of the document library to be replicated in the file share.
######################## Start Variables ########################
######################## Varun's Script######################
$destination = "C:\\tools\\Folder"
$webUrl = "<Url of the specific site>"
$listUrl = "<Url of the specific list. This url is complete Url and NOT relative url>"
##############################################################

$web = Get-SPWeb -Identity $webUrl
$list = $web.GetList($listUrl)

function ProcessFolder {
    param($folderUrl)
    $folder = $web.GetFolder($folderUrl)
    foreach ($file in $folder.Files) {
        #Ensure destination directory
        $destinationfolder = $destination + "/" + $folder.Url
        if (!(Test-Path -path $destinationfolder))
        {
            $dest = New-Item $destinationfolder -type directory
        }
        #Download file
        $binary = $file.OpenBinary()
        $stream = New-Object System.IO.FileStream($destinationfolder + "/" + $file.Name), Create
        $writer = New-Object System.IO.BinaryWriter($stream)
        $writer.write($binary)
        $writer.Close()
        }
}

#Download root files
ProcessFolder($list.RootFolder.Url)
#Download files in folders
foreach ($folder in $list.Folders) {
    ProcessFolder($folder.Url)
}



 Awesome Blog for PowerShell Scripts. Thank you Varun.


Powershell Script to Importing & Exporting sites in SharePoint 2010

SharePoint 2010 we can import and export sites, lists, document libraries and items using Export-SPWeb and Import-SPWeb.

Export-SPWeb http://SP/TeamSite –Path C:\Backup\website.bak

If we only want to export a list in a site you can use –ItemUrl parameter as shown below:

Export-SPWeb http://SP/TeamSite -ItemUrl “Lists/<<MyList>>” `
–Path C:\Backup\website.bak

We can use the Import-SPWeb cmdlet to import the exported files to SharePoint 2010.

Import-SPWeb http://SP/TeamSite –Path C:\Backup\website.bak


Tuesday, September 4, 2012

Redirect from NewForm.aspx to DispForm.aspx or EditForm.aspx of newly created item


Redirect from NewForm.aspx to DispForm.aspx or EditForm.aspx of newly created item.

You may need to redirect from NewForm.aspx to DispForm.aspx (or other page) of newly created item when creating SharePointsolutions like Invoices and Orders management. There are a couple of blogs out there that already have a solution for this. Because at the moment of item creation there is no item ID yet all we can do is to redirect to other page where we can query SharePoint list using web services for the last created item by current user. Then we can just redirect to wanted page using queried item ID.

Thanks to SharePoint Drive team.

http://www.sharepointdrive.com/blog/redirect-from-newform-aspx-to-dispform-aspx-or-editform-aspx-of-newly-created-item/


HTTP Context:
http://www.entwicklungsgedanken.de/2008/03/27/redirecting-from-newformaspx-to-dispformaspx-after-creating-a-new-item/



USE THE BELOW CODE IN ITEM ADDING EVENT
Using
SPSite site = new SPSite(properties.SiteId))          
{
using (SPWeb web = site.OpenWeb(properties.RelativeWebUrl))
 {
SPList list = web.Lists[properties.ListId];
DisableEventFiring();
SPListItem itemToAdd = properties.ListItem;
foreach (SPField field in itemToAdd.Fields)
{
if (!field.Hidden && !field.ReadOnlyField && field != null && field.InternalName != "Attachments")
{
if (properties.AfterProperties[field.InternalName] != "")
{
 itemToAdd[field.InternalName] = properties.AfterProperties[field.InternalName].ToString();                
           }
}
}
 itemToAdd.Update();
 EnableEventFiring();

// Redirect
SPUtility.Redirect("DispForm.aspx?ID=" + itemToAdd.ID, SPRedirectFlags.DoNotEndResponse, httpCurrentCtx);

 }