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.