Tuesday, March 15, 2011

Customize the Display of Quick Launch (sharepoint 2010)

 
A number of options are available to developers who want to customize the appearance and behavior of Quick Launch, the menu in the left navigational area of pages in a Microsoft SharePoint Foundation website. One very commonly used technique is to modify attributes of the control that renders the Quick Launch menu. Another approach is to replace the menu control with an altogether different type of navigational control. This topic gives examples that use both methods.



Modifying the menu control

You can modify the appearance of Quick Launch by setting attributes on the AspMenu control that displays its navigational nodes. For example, you can set attributes that collapse the view of the menu to headings alone and add flyout menus for displaying subordinate menu levels.
The menu control is defined in the default master page for the website. To change characteristics of the menu, you must either customize the originally installed default master page or create a custom master page and set it as the default.
To display flyout menus by modifying the default master page
  1. Open your browser and navigate to the website that you want to customize.
  2. Click Site Actions, and then click Site Settings.
  3. In the Galleries section, click Master pages.
  4. Select v4.master. Then click Edit Document on the ribbon.
The master page opens in the default editor. If Microsoft SharePoint Designer 2010 is installed on your computer, the file opens in SharePoint Designer.
  1. Close your browser.
Note
You might not be allowed to save changes to the site's default master page if a site-mapped page is open.
  1. Locate the Quick Launch menu control. You can find the control in code view by searching on the following string: <SharePoint:AspMenu id="V4QuickLaunchMenu"
  2. Set the value of the StaticDisplayLevels attribute and the MaximumDynamicDisplayLevels attribute to 1, as follows.
<SharePoint:AspMenu id="V4QuickLaunchMenu" runat="server"
    EnableViewState="false" DataSourceId="QuickLaunchSiteMap"
    UseSimpleRendering="true" UseSeparateCss="false" Orientation="Vertical"
    StaticDisplayLevels="1" MaximumDynamicDisplayLevels="1"
    SkipLinkText="" CssClass="s4-ql" />


By default, the StaticDisplayLevels attribute is set to 2. This means that when the page is rendered, the Quick Launch area of the left navigation bar has two menu levels: a series of headings and, below each heading, a set of child links. Changing the value to 1 means that only headings are shown.
The default value of the MaximumDynamicDisplayLevels attribute is 0. This disables flyout menus. Setting the value to 1 means that the first menu level below the last level on the static menu appears in a flyout menu. In this case, flyoutmenus appear for the first level below the headings.
  1. Save the file and open a page in the website to see the result of your changes.
To display flyout menus by creating a custom master page
  1. In SharePoint Designer 2010, open the website that you want to customize.
  2. In the Navigation pane, select Master Pages.
  3. Right-click v4.master, and then click Copy.
  4. Right-click an empty area of the Master Pages pane, and then click Paste.
The file v4_copy(1).master is created.
  1. Right-click v4_copy(1).master, click Rename, and type a new name, such as my.master.
  2. Open the new file for editing.
  3. Locate the Quick Launch menu control. You can find the control in code view by searching on the following string: <SharePoint:AspMenu id="V4QuickLaunchMenu"
  4. Set the value of the StaticDisplayLevels attribute and the MaximumDynamicDisplayLevels attribute to 1, as follows.
<SharePoint:AspMenu id="V4QuickLaunchMenu" runat="server"
    EnableViewState="false" DataSourceId="QuickLaunchSiteMap"
    UseSimpleRendering="true" UseSeparateCss="false" Orientation="Vertical"
    StaticDisplayLevels="1" MaximumDynamicDisplayLevels="1"
    SkipLinkText="" CssClass="s4-ql" />
  1. On the File menu, click Save.
Note
You might not be allowed to save changes to the site's default master page if a site-mapped page is open in the browser. If this occurs, close the browser and try again.
  1. In the Navigation pane, select Master Pages.
  2. Right-click the name of your master page, and then click Set as Default Master Page.
Note
You can also set a custom master page as the default master by writing code that sets the value of the SPWeb.MasterUrl property.
  1. Open a page in the website to see the result of your changes.



Replacing the Menu Control

You can replace the AspMenu control with another control, such as the SPTreeView control that displays a tree of nodes that collapse and expand.
To replace the Menu control with a TreeView control
  1. In SharePoint Designer 2010, open the website that you want to customize.
  2. In the Navigation pane, select Master Pages.
  3. Right-click v4.master, and then click Copy.
  4. Right-click an empty area of the Master Pages pane, and then click Paste.
The file v4_copy(1).master is created.
  1. Right-click v4_copy(1).master, click Rename, and type a new name, such as my.master.
  2. Open the new file for editing.
  3. Locate the Quick Launch menu control. You can find the control in code view by searching on the following string: <SharePoint:AspMenu id="V4QuickLaunchMenu"
  4. Right click V4QuickLaunchMenu, select Select Tag, and then press the Delete key.
  5. Replace the deleted markup with markup for three new controls, an SPHierarchyDataSourceControl and an SPRememberScroll control that contains an SPTreeView control.
<SharePoint:SPHierarchyDataSourceControl
      id="MyTreeViewDataSource"
      runat="server" RootContextObject="Web"
      IncludeDiscussionFolders="true" />
<SharePoint:SPRememberScroll
      id="MyTreeViewRememberScroll"
      runat="server" onscroll="javascript:_spRecordScrollPositions(this);"
      Style="overflow: auto;height: 400px;width: 150px; ">
  <SharePoint:SPTreeView
        id="MyWebTreeView"
        runat="server"
        ShowLines="true"
        DataSourceId="MyTreeViewDataSource"
        ExpandDepth="3"
        SelectedNodeStyle-CssClass="ms-tvselected"
        NodeStyle-CssClass="ms-navitem"
        NodeStyle-HorizontalPadding="2"
        NodeStyle-VerticalPadding="5"
        SkipLinkText=""
        NodeIndent="20"
        ExpandImageUrl="/_layouts/images/tvplus.gif"
        CollapseImageUrl="/_layouts/images/tvminus.gif"
        NoExpandImageUrl="/_layouts/images/tvblank.gif" />
</SharePoint:SPRememberScroll>

This markup expands the top three nodes by default, specifies lines drawn between nodes, and specifies values for vertical padding and indentation.
  1. On the File menu, click Save.
Note
You might not be allowed to save changes to the site's default master page if a site-mapped page is open in the browser. If this occurs, close the browser and try again.
  1. In the Navigation pane, select Master Pages. Right-click the name of your master page, and then click Set as Default Master Page.
  2. Open a page in the website to see the result of your changes.


Wonderful information from msdn

Wednesday, March 9, 2011

SharePoint 2010 and Adobe PDF

The following post is an update from the original ‘SharePoint 2007 and Adobe PDF‘ post written in 2007. These notes are based on SharePoint 2010 Beta 2 (made publicly available in November 2009). Once the product has officially launched on 12 May 2010, an update will be posted if any changes are made to the process. The process is very similar to SharePoint 2007, with minor changes to folder location (14 instead of 12) and a slightly different administration user interface in the browser.
SharePoint 2010 and Adobe PDF
SharePoint Server 2010, like its predecessors, includes indexing and search capabilities. But what doesn’t come out of the box is the ability to index and search for PDF documents. PDF is a format owned by Adobe, not Microsoft. If you want to be able to find Adobe PDF documents, or have the PDF icon appear when viewing PDF files in a SharePoint document library (see image above), you will need to set it up for yourself. This post describes how to.
  1. Download and install Adobe’s 64-bit PDF iFilter*1http://www.adobe.com/support/downloads/detail.jsp?ftpID=4025
  2. Download the Adobe PDF icon (select Small 17 x 17) – http://www.adobe.com/misc/linking.html
    1. Give the icon a name or accept the default: ‘pdficon_small.gif’
    2. Save the icon (or copy to) C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\IMAGES
  3. Edit the DOCICON.XML file to include the PDF icon
    1. In Windows Explorer, navigate to C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\XML
    2. Edit the DOCICON.XML file (I open it in NotePad, you can also use the built-in XML Editor)
    3. Ignore the section <ByProgID> and scroll down to the <ByExtension> section of the file
    4. Within the <ByExtension> section, insert <Mapping Key=”pdf” Value=”pdficon_small.gif” /> attribute. The easiest way is to copy an existing one – I usually just copy the line that starts <Mapping Key=”png”… and replace the parameters for Key and Value (see image below)
    5. Save and close the file
      SharePoint 2010 and Adobe PDF DOCICON.XML
  4. Add PDF to the list of supported file types within SharePoint
    1. In the web browser, open SharePoint Central Administration
    2. Under Application Management, click on Manage service applications
    3. Scroll down the list of service apps and click on Search Service Application
    4. Within the Search Administration dashboard, in the sidebar on the left, click File Types
    5. Click ‘New File Type’ and enter PDF in the File extension box. Click OK
    6. Scroll down the list of file types and check that PDF is now listed and displaying the pdf icon.
    7. Close the web browser
  5. Stop and restart Internet Information Server (IIS)*2 Note: this will temporarily take SharePoint offline. Open a command line (Start – Run – enter ‘cmd’) and type ‘iisreset’
  6. Perform a full crawl of your index. Note: An incremental crawl is not sufficient when you have added a new file type. SharePoint only indexes file names with the extensions listed under File Types and ignores everything else. When you add a new file type, you then have to perform a full crawl to forcibly identify all files with the now relevant file extension.
That’s it. If you now perform a search, PDF files should be displayed in results where they match the search query, along with the PDF icon on display in results. The icon should also be visible in any document libraries that contain PDF files.
* Additional Notes:
  1. At time of writing, Adobe has published PDF iFilter 9 for 64-bit applications, tested on SharePoint 2007 but not yet listed as tested on SharePoint 2010. So far, it is working fine on my builds of SharePoint 2010 (Beta versions)
  2. When setting this up, I initially just restarted the search service rather than IIS but found myself locked out of SharePoint. Resetting IIS fixed it. I don’t know for certain if you also need to restart the search service. Will test on the next build and update here.
  3. As with SharePoint 2007, there are alternative PDF ifilters. The most well known is Foxit Pro – http://www.foxitsoftware.com/. Rumoured to perform indexing faster than using Adobe’s iFilter. I can’t comment, I haven’t tested it. Given PDFs don’t change (they are usually PDFs specifically to not be edited) they are only indexed when first uploaded or when you perform a full crawl. Most organisations should primarily be performing incremental crawls – updating the index with content that has been added or changed rather than re-indexing everything


Information kindly given by Sharon Richardson

Friday, February 25, 2011

Access denied while doing a restore

I recently faced the problem of having powershell and normal command line stsadm giving me the "Access denied" error when trying to restore a sharepoint site.
Here is how I fixed it.
1. Run cmd or powershell as an administrator
2. Make sure that you are a farm admin
3. Make sure the user belongs to the following groups:
  • Administrators
  • IIS_WPG 
  • WSS_WPG
  • WSS_ADMIN_WPG 
  • WSS_RESTRICTED_WPG
And that fixed my issue.

Monday, January 10, 2011

Call your custom CSS in sharepoint

When you wish to use your own custom Css in sharepoint but do not know how to call it in your master page, use the following line in the <head> of your master page:


<SharePoint:CssRegistration name="<%$SPUrl:~SiteCollection/Style Library/~language/Core Styles/Style.css%>" runat="server"/>


"~language" must be changed to the language in which your style is, i.e: en-us


or you can use the following line:


<SharePoint:CssRegistration name="~url of stylesheet" runat="server"/>

Thursday, December 2, 2010

Hiding the Quick Launch in SharePoint 2010


Hiding the Quick Launch in SharePoint 2010

At times one would really feel no need of the Quick Launch section on few pages or sites i.e. the Team Site, one would really love to use the full width of the page for this one. Luckily the Content Editor Web Part trick which worked in SharePoint 2007 still works in 2010.
To hide the Quick Launch
1. Add a new Content Editor webpart. (Doesn’t matter where you add it)
2. Edit the HTML Source for the newly added Content Editor Webpart
3. In the HTML Source add the following and Click OK.
#s4-leftpanel{
display:none
}
.s4-ca{
margin-left:0px
}
[Do not forget to add the style open and close tag as seen in below image due to rendering issues its not showing up]
4. Save the Page. The Quick Launch section should not be visible now.
5. Edit the Just added Content Editor web Part and Under Layout Section Tick the Hidden Check box and Click OK, Which will hide the Webpart from Normal View.
6. This works on any SharePoint 2010 or Foundation 2010 Page and site.

This information comes from The Communicator