среда, 28 декабря 2011 г.

Creating custom PortalSiteMapProvider for SharePoint Portal 2010

This provider ables to remove navigation from Cities list and add items from Members list.
CustomNavigationDataProvide.cs

namespace SiteGroup.WebControls
{
    public class CustomNavigationDataProvider : PortalSiteMapProvider
    {
        public override System.Web.SiteMapNodeCollection GetChildNodes(System.Web.SiteMapNode node)
        {

            PortalSiteMapNode portalNode = (PortalSiteMapNode)node;

            SPQuery query = new SPQuery() { Query = "" };
           
            // Remove nodes wich include in "Cities" list

            SiteMapNodeCollection nodeCities = this.GetCachedListItemsByQuery(
                    portalNode.WebNode, "Cities", query, SPContext.Current.Web);
            foreach (SiteMapNode nodeCity in nodeCities)
            {
                for (int nNodeIndex = coll.Count - 1; nNodeIndex >= 0; nNodeIndex--)
                {
                    if (coll[nNodeIndex].Title == nodeCity.Title)
                    {
                        coll.RemoveAt(nNodeIndex);
                    }
                }
            }
            // Add nodes to Members node
            if (node.Title == "Members")
            {
               // PortalSiteMapNode portalNode = (PortalSiteMapNode)node;

                //SPQuery query = new SPQuery() { Query = "" };
                SiteMapNodeCollection listItemNodes = this.GetCachedListItemsByQuery(
                        portalNode.WebNode, "Members", query, SPContext.Current.Web);


                coll = new SiteMapNodeCollection(listItemNodes.Count);
               
                SPWeb web = SPContext.Current.Site.RootWeb;
                Guid guidBank = web.Lists["Members"].ID;
                foreach (PortalListItemSiteMapNode nodeList in listItemNodes)
                {
                    PortalSiteMapNode nodeNew = new PortalSiteMapNode(
                        portalNode.WebNode,
                        string.Format("{0}_add", nodeList.Key),
                        Microsoft.SharePoint.Publishing.NodeTypes.ListItem,
                        nodeList.Url,
                        nodeList.Title,
                        nodeList.Description);
                    coll.Add(nodeNew);
                }

                return coll;
            }

            return coll;
        }
    }
}

Creating Navigation module

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Control
    Id="TopNavigationDataSource"
    Sequence="40"
    ControlClass="Microsoft.SharePoint.Publishing.Navigation.PortalSiteMapDataSourceSwitch"
    ControlAssembly="Microsoft.SharePoint.Publishing, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">
    <Property Name="ID">topSiteMap</Property>
    <Property Name="SiteMapProvider">
CustomNavigationDataProvider</Property>
    <Property Name="EnableViewState">false</Property>
    <Property Name="StartFromCurrentNode">true</Property>
    <Property Name="ShowStartingNode">true</Property>
    <Property Name="TreatStartingNodeAsCurrent">true</Property>
    <Property Name="TrimNonCurrentTypes">Heading</Property>
  </Control>
</Elements>

web.config registration

<actions>
  <add path="configuration/system.web/siteMap/providers">
    <add name="LifeGlobalNavSiteMapProvider" description="" type="SiteGroup.WebControls.
CustomNavigationDataProvider, SiteGroup, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ce31f39e24cadf59" NavigationType="Combined" EncodeOutput="true" />
  </add>
</actions>


You need to activate feature with Navigation module.

пятница, 23 декабря 2011 г.

Как получить информацию о Feature SharePoint 2010

Get-SPFeature -Identity "ADV.Life_List instances" | Format-List Пример
Get-SPFeature -Identity "SearchWebParts" | Format-List
PS C:\Users\Administrator.SP> Get-SPFeature -Identity "SearchWebParts" | Format-List


Name : FeatureDefinition/eaf6a128-0482-4f71-9a2f-b1c650680e77
Id : eaf6a128-0482-4f71-9a2f-b1c650680e77
DisplayName : SearchWebParts
SolutionId : 00000000-0000-0000-0000-000000000000
ReceiverAssembly :
ReceiverClass :
UIVersion :
UpgradeReceiverAssembly :
UpgradeReceiverClass :
Properties : {}
Version : 12.0.0.0
Scope : Site
AutoActivateInCentralAdmin : False
ActivateOnDefault : True
RootDirectory : C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\Template\FeaturesSearchWebParts
Hidden : False
ActivationDependencies : {}
AlwaysForceInstall : False
RequireResources : False
DefaultResourceFile : Microsoft.Office.Server.Search
TypeName : Microsoft.SharePoint.Administration.SPFeatureDefinition
Status : Online
Parent : SPFarm Name=SharePoint_Config
Farm : SPFarm Name=SharePoint_Config
UpgradedPersistedProperties : {}

среда, 7 декабря 2011 г.

Как убрать задержку при открытии выпадающего меню SharePoint

При открытии динамического подменю SharePoint 2010 на базе AspMenu возникает задержка при перемещении на другой пункт меню. Чтобы исправить это, достаточно добавить следующий стиль. li.hover-off>ul { display:none; } см. также http://blog.voltje.be/?p=208

понедельник, 5 декабря 2011 г.

How to get ImageList in SharePoint 2010

PublishingWeb pubSite = PublishingWeb.GetPublishingWeb(SPControl.GetContextWeb(HttpContext.Current)); pubSite.ImagesLibrary