Wednesday, May 15, 2013

Date Conversions/Calculated Fields - SP List

If you need to convert Article Date = '01/01/2013' to 'January 2013, you need to do the following
  • Add a new column to SP List
  • The type of the column is calculated.
  • Insert this formula to get the desired out come. [=TEXT([Article Date],"mmmm")&" "&TEXT([Article Date],"yyyy")]
If you need to convert Article Date = '01/01/2013' to '01 January', you need to do the following:

  • Follow steps 1&2
  • =TEXT(MONTH([Article Date]),"00")&" "&TEXT([Article Date],"mmmm")

Sunday, May 12, 2013

Display Content Editor WebPart only when it contains Content.

  • Define a Page Layout
  • Add a class to the section. - (Example: mainLayout)
  • Add another class to wrap a CE in this section. - (Example: controlContainer)
  • If there is a line break after the page layout, add an id to that control (Example: <BR Id='lineBreak' />
  • Here is the code to add to you .JS file.
        if ($('#mainLayout.controlContainer').length == 0)
        {
            $('#mainLayout').addClass('hidden');
            $('#lineBreak').addClass('hidden');
        };
   
   
        loadedStylesheets = document.styleSheets;
   
        for (var i in loadedStylesheets)
        {
            var findEditStyle = "https://SERVER/Style%20Library/en-US/Themable/Core%20Styles/editmode15.css"
                if (findEditStyle == loadedStylesheets[i].href)
                {
                    $('#mainLayout').removeClass('hidden');
                    $('#lineBreak').removeClass('hidden');
                };
           
        }

Using Jquery to determine Page in Edit Mode O365

If you have a scenario where you need to determine if the page is edit mode and display a control/container. Here is the approach

  • Define the container with a unique ID/Class
  • Add JQuery to some .js file.
  • Ensure that editmode15.css is loaded in one of the edit panels of the page layout associated with this page. Alternatively, you could also add something else in an edit panel and then check that going through the DOM object.
  • Then, add code like below.
        loadedStylesheets = document.styleSheets;
   
        for (var i in loadedStylesheets)
        {

            var findEditStyle = "https://SERVER/Style%20Library/en-US/Themable/Core%20Styles/editmode15.css"
                if (findEditStyle == loadedStylesheets[i].href)
                {
                    $('#YourID').removeClass('hidden');
                    $('#YourExtraIDs').removeClass('hidden');
                };
           
        }

Determine if

//Hiding the News From Leaders Section and making it visible in Edit Mode.
        /*
        check to see if WPEditModev4.css is loaded
        if so, this means you're in "edit" mode
        */
        // check to see if no news elements exist in 'News From Our Leaders' section
        if ($('#nLeader .articleContainer').length == 0)
        {
            $('#nLeader').addClass('hidden'); // hide the parent container if no articles
            $('#LeaderBreak').addClass('hidden');
        };
   
   
        loadedStylesheets = document.styleSheets;
   
        for (var i in loadedStylesheets)
        {
            //This path would be fixed as this is being loaded from the page layout.
            var findEditStyle = "https://yumbrandsinc.sharepoint.com/sites/ynn/Style%20Library/en-US/Themable/Core%20Styles/editmode15.css"
            var findStylesheet = "WPEditModev4.css";
                //var currentStylesheet = (loadedStylesheets[i].href.match(/\/([^/]+)$/)[1]);
                if (findEditStyle == loadedStylesheets[i].href)
                {
                    $('#nLeader').removeClass('hidden');
                    $('#LeaderBreak').removeClass('hidden');
                };
           
       

Monday, May 6, 2013

Hide Office365 Logo on SP 2013 sites

Comment the following line in the master page:
                    <!--<SharePoint:DelegateControl id="ID_SuiteBarBrandingDelegate" ControlId="SuiteBarBrandingDelegate" runat="server" />-->

If the above approach does not work, you could use CSS to hide.

Tuesday, April 30, 2013

SP Designer Caching Issues

Issue - If you want to clear up the SharePoint Designer Cache
Resolution - Delete everything from this location %USERPROFILE%\AppData\Local\Microsoft\WebsiteCache
SPD 2007, SPD 2010, SPD 2013


Issue - If you want to remove the recent sites when you open SPD.
Resolution - Goto this location %USERPROFILE%\AppData\Local\Microsoft\WebsiteCache and open WebSites.XML file to remove any entry you want.


Note: When you uninstall SPD, this above file is never deleted.
SPD 2007, SPD 2010, SPD 2013

Monday, April 29, 2013

Hide "Share" & "Follow" & "Focus Icon" From Home Page Master Page in SP2013

Comment the following controls on MasterPage..


<!-- Removes Share Button -->
                        <!--<SharePoint:SPSharePromotedActionButton runat="server"/>-->
                        <!--Removes Follow Button-->
                        <!--<SharePoint:DelegateControl runat="server" ControlId="PromotedActions" AllowMultipleControls="true" />-->


<!--<span id="fullscreenmodebox" class="ms-qatbutton">
                    <span id="fullscreenmode">
                        <SharePoint:ThemedClusteredHoverImage
                        runat="server"
                        ID="fullscreenmodeBtn"
                        ThemeKey="spcommon"
                        TouchMode="true"
                        TouchModeWidth="30"
                        TouchModeHeight="30"
                        TouchModePaddingLeft="7"
                        TouchModePaddingTop="7"
                        TouchModePaddingRight="7"
                        TouchModePaddingBottom="7"
                        ImageUrl="/_layouts/15/images/spcommon.png?rev=23"
                        Width="16"
                        Height="16"
                        OffsetX="143"
                        OffsetY="178"
                        HoverOffsetX="125"
                        HoverOffsetY="178"
                        NavigateUrl="#"
                        onclick="SetFullScreenMode(true);PreventDefaultNavigation();return false;"
                        AlternateText="<%$Resources:wss,multipages_fullscreenmodelinkalt_text%>"
                        ToolTip="<%$Resources:wss,multipages_fullscreenmodelinkalt_text%>"
                        />
                    </span>
                    <span id="exitfullscreenmode" style="display: none;">
                        <SharePoint:ThemedClusteredHoverImage
                            runat="server"
                            ID="exitfullscreenmodeBtn"
                            ThemeKey="spcommon"
                            TouchMode="true"
                            TouchModeWidth="30"
                            TouchModeHeight="30"
                            TouchModePaddingLeft="7"
                            TouchModePaddingTop="7"
                            TouchModePaddingRight="7"
                            TouchModePaddingBottom="7"
                            ImageUrl="/_layouts/15/images/spcommon.png?rev=23"
                            Width="16"
                            Height="16"
                            OffsetX="107"
                            OffsetY="178"
                            HoverOffsetX="179"
                            HoverOffsetY="96"
                            NavigateUrl="#"
                            onclick="SetFullScreenMode(false);PreventDefaultNavigation();return false;"
                            AlternateText="<%$Resources:wss,multipages_fullscreenmodelinkalt_text%>"
                            ToolTip="<%$Resources:wss,multipages_fullscreenmodelinkalt_text%>"
                            />
                    </span>
                </span>-->



Tuesday, April 16, 2013

Export/Import TermStore without any code (Exception XSLT) especially for O365

  •     Use Office 2010 client to the output from the web server.
  •     In SP2010, create a new document library.
  •     Add a MM type column.
  •     Open MSFT Word 2010 and save the document lib in the SP lib.
  •     Goto %LOCALAPPDATA%\Microsoft\Office\TermSets and look for GUID.XML file that was recently added. (Note: Ensure you hidden files are viewable)
  •     Select this file and copy it to you folder.
  •     Use XSLT to transfer this content into the Format required to Import CSV.
       
        Here is a document from MSFT, which provides details on the format
        http://technet.microsoft.com/en-us/library/ee424396%28v=office.14%29.aspx