SharePoint 2013 Can't edit the Content Editor snippet - sharepoint-2013

In SharePoint 2013 it is possible to create master pages and page layouts using the new Design Manager. After converting a HTML file to a masterpage, or after creating a new page layout, one can add SharePoint functionality by using the Snippet Manager. I have used this approach to convert a static HTML/CSS file into an SharePoint masterpage with accompanying page layouts. I'm able to use all the snippets from the Snippet Manager, except for the "Content Editor" snippet. I was able to add top navigation, the quick launch bar, page properties and even "Web Part Zone" snippets.
The usecase:
I want to have a editable footer. The footer consists of four parts, so I added four Content Editor snippets, by pasting the snippet code into the HTML masterpage. When generating a snippet, it's possible to set custom properties. I noticed that it's not possible to set the WebPartID over here. In the snippet, the following WebPartID is always used: 00000000-0000-0000-0000-000000000000. The "Web Part Zone" snippet however will generate a (random?) WebPartID (and works).
The problem:
Adding the snippet works fine, but when I publish the master page or page layout it's not possible to edit the CEWP. When I edit a page which uses either the master page or the page layout, the CEWP should transform to an editable region, but it doesn't. There is no error shown. The webpart renders itself correctly.
What I tried:
I tried filling in a random WebPartID, but that doesn't work. Searching on Google and on StackOverflow didn't gave me any clues, I can't find anyone facing the same problem.
The code:
The following snippet is generated:
<!--CS: Start Content Editor Snippet--><!--SPM:<%#Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"%>--><!--MS:<WebPartPages:ContentEditorWebPart xmlns:WebPartPages="namespace" runat="server" webpart="true">--><!--PS: Start of READ-ONLY PREVIEW (do not modify)--><div class="ms-webpart-chrome ms-webpart-chrome-fullWidth "><div WebPartID="00000000-0000-0000-0000-000000000000" HasPers="true" id="WebPart" width="100%" class="ms-WPBody noindex " OnlyForMePart="true" allowMinimize="false" allowRemove="false" allowDelete="false" style=""><div class="ms-rtestate-field"></div><div class="ms-clear"></div></div></div><!--PE: End of READ-ONLY PREVIEW--><!--MS:<WebPart xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/WebPart/v2">--><!--MS:<Title>--><!--SPM:$Resources:core,ContentEditorWebPartTitle;--><!--ME:</Title>--><!--MS:<FrameType>--><!--SPM:None--><!--ME:</FrameType>--><!--MS:<Description>--><!--SPM:$Resources:core,ContentEditorWebPartDescription;--><!--ME:</Description>--><!--MS:<IsIncluded>--><!--SPM:true--><!--ME:</IsIncluded>--><!--MS:<ZoneID>--><!--SPM:ImportedPartZone--><!--ME:</ZoneID>--><!--MS:<PartOrder>--><!--SPM:0--><!--ME:</PartOrder>--><!--MS:<FrameState>--><!--SPM:Normal--><!--ME:</FrameState>--><!--MS:<Height>--><!--ME:</Height>--><!--MS:<Width>--><!--ME:</Width>--><!--MS:<AllowRemove>--><!--SPM:false--><!--ME:</AllowRemove>--><!--MS:<AllowZoneChange>--><!--SPM:false--><!--ME:</AllowZoneChange>--><!--MS:<AllowMinimize>--><!--SPM:false--><!--ME:</AllowMinimize>--><!--MS:<AllowConnect>--><!--SPM:true--><!--ME:</AllowConnect>--><!--MS:<AllowEdit>--><!--SPM:true--><!--ME:</AllowEdit>--><!--MS:<AllowHide>--><!--SPM:false--><!--ME:</AllowHide>--><!--MS:<IsVisible>--><!--SPM:true--><!--ME:</IsVisible>--><!--MS:<DetailLink>--><!--ME:</DetailLink>--><!--MS:<HelpLink>--><!--ME:</HelpLink>--><!--MS:<HelpMode>--><!--SPM:Modeless--><!--ME:</HelpMode>--><!--MS:<Dir>--><!--SPM:Default--><!--ME:</Dir>--><!--MS:<PartImageSmall>--><!--ME:</PartImageSmall>--><!--MS:<MissingAssembly>--><!--SPM:Cannot import this Web Part.--><!--ME:</MissingAssembly>--><!--MS:<PartImageLarge>--><!--SPM:/_layouts/15/images/mscontl.gif--><!--ME:</PartImageLarge>--><!--MS:<IsIncludedFilter>--><!--ME:</IsIncludedFilter>--><!--MS:<ExportControlledProperties>--><!--SPM:true--><!--ME:</ExportControlledProperties>--><!--MS:<ConnectionID>--><!--SPM:00000000-0000-0000-0000-000000000000--><!--ME:</ConnectionID>--><!--MS:<ID>--><!--SPM:g_2bfa6a66_54d1_45e6_84e7_ebbb461f2911--><!--ME:</ID>--><!--MS:<ContentLink xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor">--><!--ME:</ContentLink>--><!--MS:<Content xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor">--><!--ME:</Content>--><!--MS:<PartStorage xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor">--><!--ME:</PartStorage>--><!--MS:<ID>--><!--SPM:g_a4deccb6_9661_415d_99c8_51f528cf7428--><!--ME:</ID>--><!--ME:</WebPart>--><!--ME:</WebPartPages:ContentEditorWebPart>--><!--CE: End Content Editor Snippet-->
This generates the following code in the .master file:
<WebPartPages:ContentEditorWebPart runat="server" webpart="true" __WebPartId="{B2063517-7C26-4084-AA28-36434C760CDB}"><WebPart xmlns="http://schemas.microsoft.com/WebPart/v2"><Title>$Resources:core,ContentEditorWebPartTitle;</Title><FrameType>None</FrameType><Description>$Resources:core,ContentEditorWebPartDescription;</Description><IsIncluded>true</IsIncluded><PartOrder>0</PartOrder><FrameState>Normal</FrameState><Height /><Width /><AllowRemove>false</AllowRemove><AllowZoneChange>false</AllowZoneChange><AllowMinimize>false</AllowMinimize><AllowConnect>true</AllowConnect><AllowEdit>true</AllowEdit><AllowHide>false</AllowHide><IsVisible>true</IsVisible><DetailLink /><HelpLink /><HelpMode>Modeless</HelpMode><Dir>Default</Dir><PartImageSmall /><MissingAssembly>Cannot import this Web Part.</MissingAssembly><PartImageLarge>/_layouts/15/images/mscontl.gif</PartImageLarge><IsIncludedFilter /><ExportControlledProperties>true</ExportControlledProperties><ConnectionID>00000000-0000-0000-0000-000000000000</ConnectionID><ID>g_2bfa6a66_54d1_45e6_84e7_ebbb461f2911</ID><ContentLink xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor" />
<Content xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor"><![CDATA[]]></Content>
<PartStorage xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor" /><ID>g_a4deccb6_9661_415d_99c8_51f528cf7428</ID></WebPart></WebPartPages:ContentEditorWebPart>
Some more information:
I'm pasting the snippets in the HTML file, as indicated. When I add a Web Part Zone snippet, I'm able to add working "Content Editor" WebParts in it. "Web Part Zone" snippets are only available in the Page Layout Snippet Manager though, so I can't use that as a workaround to get the footer in the masterpage to work.
My questions:
How can I add a Content Editor WebPart through the Snippet Manager?
Are there others facing the same problem?
Is it okay to leave the WebPartID 00000000-0000-0000-0000-000000000000?

Having fought a bit with SharePoint on this, this is what I found:
There are two different ways the Snippets created by the Snippet Manager work. If they are put anywhere within the html code of your Masterpage or Page Layouts, they will have the exact same configurations as the ones you select on the Snippet Editor, and you won't be able to edit them afterwards.
However, if you put them inside a Webpart Container Snippet code, you will be able to edit the webparts when accessing the Edit Page feature on SharePoint. As you probably figured out, this only works on page layouts and not on masterpages.
I believe a way to have a dynamic footer, is to use a Content By Search Web part and point it to a specific List (Footer List) and on that list you can have a column with a Rich Text Editor type, and then you can create a specific Display Template that will render the list content as desired.
Hope it makes some sense.

Related

Sitecore 9 - Add an Image to a Link in the Footer

A client is using Sitecore 9 - we are not Sitecore developers.
We've been asked a simple thing: add social media links to the Footer of their Sitecore site.
Its proving more difficult than expected.
I've added the links on other pages by editing the HTML directly via the WYSWIG editor.
But the Footer appears more restricted, only accepting the addition of templates like 'Link'.
The 'Link' template has an option to add an external URL but doesn't have an option to add an image.
The CMS looks like this:
Is there any way to add a link, with an image, via the CMS (without the need to write Sitecore code), so the page chnages from this:
to this:
If you dont want to write Sitecore code, maybe you should think about using frontend.
Find the views that holds the footer (probably Foundation/Footer.cshtml) or something like that.
-To easily find where it is, follow these steps
Go to a content page Presentation Details that has footer (probably any)
Go to Controls
Find the footer rendering in there
Click on it
Grab the Datasource's value
Go to the Datasource's path
There should be a field holding the value of the view.
Add some css class on the div that holds those items, and do your frontend stuff in there...
It is not a scalable solution, so I would highly recommend updating the Footer rendering by adding new fields and adapting the model/view. So that way a content editor could easily add a new value for each socials.

Display template for content search webpart issue for datatable and Tabs

I have developed display template and using it in Content search web part.
For displaying result on page i am using JQuery datatable/JQuery Tabs in display template.
Everything works fine, but sometime while loading page i am getting error like ("Object doesn't support property or method 'dataTable' (OnPostRender: )" and for tabs error is "Object doesn't support property or method 'tabs' (OnPostRender: )").
And if i refresh page many times then error will go and result is display as code.
I have register JQuery, JS and CSS using $includeScript.
I have also tried with RegisterSod for JQuery and JS file but still issue is same.
Thanks in Advance.
Can be:
This error usually occurs when an html element id has the same id as some variable in the javascript function, try change the name.
If you put the code I'll be able to help you better.
test = button.attr('test'); // Object doesnt support this method
$test= button.attr('test'); // works fine
Or debbug your code with and discover your problem. Enable script debugging IE:
In Internet Explorer, choose Internet Options from the Tools menu.
In the Internet Options dialog box, click the Advanced tab.
On the Advanced tab, under Browsing, clear Disable Script Debugging.
Click OK.
If you have IE 8+ click here
Tutorial Using jQuery dataTables: link here

How to edit plugin to use the theme's template files

I am using a theme called Hemingway, it's a great theme with three page layouts. (full-width, with sidebar, without sidebar). This is all working great. I can choose one of three options in page settings.
I'm also using the Projects plugin by Woothemes. This plugin makes it easy to add recent projects with a photo gallery and some other options. It's working when I'm using the shortcode:
[projects limit="12" columns="2" orderby="date" order="desc" exclude_categories=""]
I'm using this shortcode with two columns on a full-width template. This is working great, but when I'm trying to use the functionality to automatically add the content of projects to the page using the option built-in Projects:
The full-width template is not working and the sidebar is shown. Also the two column layout for projects is not working. They just aligned beneath eachother.
How it should look like (this example is with shortcodes):
http://hoveniersbedrijfameland.nl/projecten/
How it looks with the option in projects to choose a page: (this is wrong)
http://hoveniersbedrijfameland.nl/projects/
How can I debug this to see what breaks it?
What I tried so far:
I've tried the plugin to behave like I want. This means, that the
plugin will use the full page template for 'categories' instead of
using the archive page. I don't really know how the plugin is build,
so it's hard to eit the right file.
I've tried a workaround with url routing, but this isn't the best
approach.
I found a solution. I copied the archive-project.php file to my theme and edited the content with the ones in the full-width template. I need to style it myself because the pages are broken if I leave it like that.
If I want to edit page template now, I need to code it in the ffile instead of choosing it from the pages > page layout in the admin panel.
I'll fix that later.
FINAL UPDATE: I hardcoded everything and it's working for me now. I don't need any further help, I'm now looking into the custom post types to change the content template.

Sitecore Experience editor showing raw JSON data

I am using a simple MVC sitecore project. I just given only one field in rendering page. When i try to view in "Experience Editor" its showing some raw JSON Data like below.
I have used this post
to solve this. when i include that webedit.css in my main layout then the Raw data vanished. But i am not able to see the Editing Ribbon. But when i choose Experience Editor from desktop its showing all Default contents correctly along with the editing Ribbon(Default Page).
Can anyone tell me why i am not able to see that editing ribbon on my page?
This is because your layout razor cshtml file has valid HTML markup skeleton in place. Please make sure at the very minimum your page is formatted like this:
#using Sitecore.MVC
<html>
<body>
#Html.Sitecore().Etc...
etc...
</body>
</html>
This should eliminate the big chunk of JSON on top and enable all page editor UI elements.

Importing HTML into TinyMCE using ColdFusion

Hey everyone, I would appreciate a pointing in the right direction with the problem I'm having. In short, I'm working on an application that will create PDFs using TinyMCE and ColdFusion 8. I have the ability to create a PDF by just entering in text, pictures, etc. However, I want to be able to import an html template and insert it into the TinyMCE .
Basically, I have a file directory code snippet that lets me browse through my 'HTMLTemplates' folder, and am able to select an HTML document. Now, I want to be able to take all the code from that selected HTML document and insert it into my TinyMCE box. Any tips on how I might do this, maybe?
Thanks!
If I understood you correctly, you already have a TinyMCE plugin which pops up a window and allows you to browse the certain directory using existing cfm page which you render within the popup window. Right?
If not, you should start with this. Not sure how easy it is done in current version, but in the older TinyMCE I've created the custom upload plugin (needed to track the site security permissions for current user) pretty quickly.
Next, I can see two quick ways to pass the server file contents to the client-side:
Make it available via HTTP so you can make the GET request and read contents into the variable.
Output it on the page using CF (say, on form submit when file selected) and grab using JavaScript.
I'd personally tried the second option. After you grab the text into the variable you can put it into the TinyMCE using it's API.
It can be as simple as output escaped text into the hidden div with known ID and read it using DOM operations (assuming that there is cfoutput around):
<div id="myTemplate">#HTMLEditFormat(myFileContents)#</div>
Also you can output the text directly into the JavaScript variable (of cource, with accurate escaping), maybe like this.
<script type="text/javascript">
var text = '#HTMLEditFormat(myFileContents)#';
</script>
Most advanced and possibly better for performance (and definitely "cooler") way is to use the concept of script tags as data containers, like this:
<script type="text/plain">
#HTMLEditFormat(myFileContents)#
</script>
Last time I've seen this in Nadel's blog, I think. Read it, pretty interesting.
Hope this helps.