I'm trying to implement web solution with sitecore 7.x as a content manager. My web application is a MVC solution. I've installed Sitecore and set up MVC project.
The problem is that AB/MV tests don't work when using *.cshtml layout with #Html.Sitecore().Placeholder(...) and ControllerRenderings.
I have Item defined with layout set to LayoutMVC.cshtml file.
#inherits System.Web.Mvc.WebViewPage
#using Sitecore.Mvc
<html>
<body>
MAIN:#Html.Sitecore().Placeholder("main")END
</body>
</html>
I render ControllerRendering into main placeholder and I want to add variation to component rendered here. Basicaly I can add a variation using Page Editor and everything is fine until I click save in Page Editor. Then the test is saved but I cannot see first variation anymore. I see the content from the original item. I can choose variations but instead of Variation1 there is a Default content.
When I start a test it doesn't work at all. Always renders original Item.
The same test works when I use /sitecore/Layout/Layouts/Sample Layout which is an aspx layout but I need to use MVC #Html.Sitecore().Placeholder(...) method as I want to render placeholders dynamically later.
Additionaly DMS works fine for this configuration. I can personalize content.
This appears to be a bug. I reproduced the behavior in v7.2 update 2. I just logged the issue with Sitecore Support and will report back with their comments.
Update
Sitecore Support has confirmed that this is a bug. I'm putting a fix together. Stay tuned.
The hotfix is available here: https://github.com/BenGGolden/Sitecore.Mvc.TestingHotfix
Related
In sitecore 8, After publishing my VS solution I am able to see few pages while for few pages I get error as "THe Controls Collection can't be modified because the control contains Code blocks i.e( <%...%>)". Please help.
This is typically caused by using code blocks in a Sitecore layout. This will work fine in the Content Editor however as soon as you go to use the Page Editor or Preview a page you will run into this error. This happens because Sitecore dynamically adds the ribbon control to the page which modifies the controls collection.
However because you've mentioned you are seeing it on a published page this may actually not be related to Sitecore and it's ribbon control at all (this can happen in vanilla Asp.net as well). It could just be happening because you are using code blocks to inject values into the header of the page and the controls you are referencing have not been rendered yet. Based on the error message included it looks like you (or at least the Active Commerce skin) may be trying build the meta tags in this fashion.
There are a few options here for solving this issue:
If trying to inject something into your JavaScript (e.g. the ClientID of a field) then do so using Page.ClientScript.RegisterClientScriptBlock.
If you are trying to inject a value into JavaScript you can also move the JavaScript block to the end of the page (before the tag) or in a script block after the control it is referencing. Having it in the will often result in this error.
Use a data binding block instead (<%# %>). If you are accessing a page property you will need to add Page.DataBind() in the Page_Load.
If those don't get you up and running share any relevant code and I should be able to help you further.
References:
http://www.tcsc.com/sitecore-layouts-and-code-blocks/ https://weblogs.asp.net/abdullaabdelhaq/how-to-fix-this-the-controls-collection-cannot-be-modified-because-the-control-contains-code-blocks-i-e-lt-gt
I am in the process of fitting Sitecore Web Forms for Marketers to a solution. For that to work I need 3 things:
The ability to inject JavaScript from a rul
Rewriting all generated code to use Foundation (instead of Bootstrap)
Be able to read the submittet data of a "changed" form. Ie. a form where there is injected extra field through JavaScript.
My initial questions for this is to the second point: How do I write these views?
I have followed this article: http://www.hhogdev.com/blog/2015/september/customizing%20wffm%20in%20sitecore%208.aspx but unfortunately He does not elaborate on how to generate proper names/ids for fields and the form.
Can anybody point me in the right direction for that?
The blog post you linked to was written based on Sitecore 8.0, and although the module is the same the implementation of WFFM has since changed (unfortunately for the worse IMO).
We are currently using WFFM with Foundation, so it is possible to have them both working together but there are a few things you have to do.
I config disable Bootstrap CSS, this will mean Bootstrap markup but without the CSS files being included. I suggest you style around the given settings as much as possible to save future upgrade issues:
<settings>
<setting name="WFM.EnableBootstrapCssRendering">
<patch:attribute name="value">false</patch:attribute>
</setting>
</settings>
If you need to edit the markup then the default views for the form field markup files can be found under: Website\Views\Form and the EditorTemplates folder under that. Here's the kicker. In versions earlier than 8.0 update-5 the markup did not use the Bootstrap helper and therefore the markup was all present. The latest implementation hides this all away and therefore harder to edit in my opinion.
If you struggle with the Bootstrap markup then take a look at the view files from WFFM 8.0 update-5 or earlier. The markup is much more obvious and you should be able to (essentially) port these over to Sitecore 8.1 and then amend the markup as required (although we have found added the correct surrounding foundation DIV's were enough)
I have no idea what you mean by point 1, but for point 3, you can't. WFFM only works on the fields that you create on the back end, any new fields you create with JS will get lost. If you need to do something clever then use a hidden field (this requires adding a custom field type unfortunately) and then populate this hidden field with the data that you need passed back to the server.
i want to add my custom application name in Sitecore Start Menu List, i'm following this article :
Adding Application Shortcut
it saying use Core database i'm using this, i couldn't find Layout studio, can any sitecore developer suggest me how to find this and finish my job. Thanks in advance.
I think the instructions you've linked to there are out of date. I've not seen that bit of UI in recent releases of Sitecore.
Working in Sitecore 6.6 I've successfully made custom applications using these instructions:
http://sdn.sitecore.net/Articles/Customizing%20Sitecore%20Client/Adding%20an%20Application%20Shortcut/Creating%20an%20Application.aspx
But beware the issue that I've blogged about here. The recent revisions of Sitecore subtly break the configuration defined above, and you have to manually edit out a file extension to make everything work:
https://jermdavis.wordpress.com/2014/10/20/a-gotcha-with-custom-applications/
-- Edited to add --
Based on the "it doesn't work in 7.5" comment below, I've tried these instructions on a test instance of Sitecore 7.5 rev 141003. It seems 7.5 behaves slightly differently - but I can still make it work.
Create the item under /sitecore/content/Applications using the external link button for the "Application" field. With raw values displayed, it should look something like:
And then create your application shortcut under /sitecore/content/Documents and settings/All users/Start menu using an internal link for the Application field. I found this still added the '.aspx' extension mentioned in my blog post, but I also found that editing it out again didn't work - it reappeared as soon as I hit save. I needed to edit out the extension from the link data using the Raw Values view in order to get the data shown below:
With those things set up, refreshing the page caused the test item to appear on my start menu:
Hopefully that works for you too?
-- Further edited to add --
New blog post covering this problem in Sitecore 7.5:
https://jermdavis.wordpress.com/2015/01/19/gotchas-with-custom-apps-v2/
Which version of Sitecore are you using? The Layout Studio is probably one of the least features in Sitecore, and personally not something I have ever used.
Instead you should create the the layout in Visual Studio - which then means your layout can be added to your Source Control System. Then follow the instructions in the link in Jeremy's answer.
If you do need to access the Layout Studio for some reason you can find it under: Sitecore menu > Development Tools > Developer Center. From there you can create new files/open existing files.
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.
I like the IntelliJ 'live edit' feature but it doesn't work for Django templates because obviously they are just a bunch of variables and its not finding the CSS files. Is there some way of working 'live' on Django templates? (or any other templating system for that matter).
Similarly I tried to use Chrome devtools autosave but it also didn't work, presumably it wants me to open an html file locally (i.e. file://).
And using chrome inspector to edit stuff is a pain because you have to copy and paste your changes - unless I'm missing something?
I am using IntelliJ 12.0.4 Ultimate with the Python plugin (this is more or less equivalent to PyCharm) to work on Django templates. It doesn't look like the Live Edit functionality works as per usual, indeed because the template has to be rendered to HTML first by Django.
One alternative is to assign a keyboard shortcut to the "View | Reload in Browser" menu item.
Another alternative is to use a Chrome plugin such as ChromeReload: You can set this to reload a specific page at a specific interval.