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');
                };
           
        }

No comments:

Post a Comment