29

You can do this by making sure that your renderings are set to Vary by User. This adds the user to the cacheKey string like this "_#user:" + Context.GetUserName(); You can then use the following code to clear the html cache for that user: // Need to clear the cache for the header and the user profile.... var htmlCache = CacheManager.GetHtmlCache(Context....


22

Layouts Provide the outermost HTML structure of a page. There is one layout (per device) per page. Apply to WebForms (.aspx) and MVC (.cshtml) Comprise of Layout definition item and aspx page (WebForms) or cshtml file (MVC) Sublayouts Provide inner HTML structure to a component or structuring element of a page. Apply only to WebForms Comprise of a ...


20

Yes, the presentation values of Item A are stored as an XML construct in the raw values of the Renderings field. You can see that field here: If you follow the blue arrows and click on Raw Values you'll see: Raw Values Method Select the rendering field value, copy, and then in Item B, do the same thing, but PASTE the field value there. Turn off Raw ...


20

Because Sitecore supports server-side responsive rendering, it's very easy to use the Device feature of the CMS to support AMP. AMP Layout (using Razor) This example is adapted from Google's example markup and Razorified: <!doctype html> <html amp lang="en"> <head> <meta charset="utf-8"> <script async src="https://cdn....


18

If you simply want to render out a partial view (either view rendering or controller rendering), from another view or layout, you could use the Sitecore MVC extension methods: Render view rendering: Html.Sitecore().ViewRendering("Path to the View") Render controller rendering: Html.Sitecore().Controller("Controller Name", "Controller Action") If you are ...


16

With Sitecore Experience Accelerator you can forget about previous methods, however, there is nothing that will block you from using them. Before - NO SXA: you had to decide how your page will look like before you entered content (because the presentation was stored either on SV or somewhere inside different branches) you couldn't easily switch your ...


15

DataSource Location inside rendering parameters has different context. You could achieve your goal by extending resolveRenderingDatasource pipeline. Allows developers to override the default logic for resolving the data source for renderings. Pipeline args type is: ResolveRenderingDatasourceArgs and it contains: public string Datasource { get; set; } ...


15

Yes. Open the presentation details of the item you want to copy from. you will see a link "Copy To" beside "Edit". You can pick which target devices you want and to which item you want to copy the presentation details


14

It is a default, used when no placeholder key is given upon inserting the rendering onto the page. This can happen both when editing via Content Editor/Presentation Details or as a result of a Conditional Rendering action. The Placeholder Rendering Property The Placeholder rendering property in the Data section of a rendering definition item ...


13

As of Sitecore 7.5+ (applies to the latest 7.2 versions as well), Sitecore introduced a media request protection for image resizing (to make sure an attacker can't overload your server with image resize requests) In this case you have two options: Add a media hash to the resizing requests, like that: Sitecore.Resources.Media.HashingUtils....


12

This is a known bug at Sitecore. We had the same problem and created a Sitecore ticket. Please use the reference number 106439 if you contact them. This is the solution though: I was able to reproduce the described behavior in my own environment and have registered this as a bug in the current version of Sitecore. As a workaround for the issue, please ...


12

This can be done by parsing the layout XML for each field (renderings and final renderings). The key is to use Sitecore.Data.Fields.LayoutField.GetFieldValue in order to obtain the XML value, otherwise you won't get the full XML with delta applied (final renderings --> shared renderings --> standard values). In Sitecore PowerShell I was able to make it work ...


11

Although .ViewRendering and .Controller will work, there are performance issues with both of those methods. Both methods will bypass Sitecore's output caching mechanism completely, so every page on your site that calls this will execute all the controllers. This may be the desired result, but most of the time we will want some kind of output caching on the ...


11

Conditional renderings work fine with MVC. For version 8, you must have Analytics.Enabled set to true so you can get to the personalization section of the presentation. "Global" conditional renderings do not work with MVC, so you need to stick to personalization of the rendering on the items presentation rather than a global rendering rule. Here is how you ...


11

The replace button doesn't appear on Experience Editor in 2 cases : When rendering doesn't have any renderings or sublayouts in Complatible Renderings field. When Renderings or sublayouts are not in Allowed Controls of the Placeholder Settings.


11

I think AlokBhatt's method is a good start, though I would make use of pipelines throughout. I think this is a better solution because it doesn't involve trying to parse presentation details, and should handle personalization and other Sitecore features. Here's an example that works for me: public string RenderItem(string itemPath) { var item = ...


10

So it's took me all of yesterday and most of today to figure this out. In the end it was nothing to do with my code or configuration at all. The log files showing some errors were a Red-Herring and leading me in the wrong direction. It is a Sitecore bug with 8.1 Update-2 (public reference: 108023). This blog post was really useful for identifying it: http:...


10

If you have Sitecore Powershell Extensions installed then there is an OOTB module available to copy/paste renderings between items. Simply right click the item, then select Scripts > Layout > Copy Renderings and then select the Paste Rendering option on the item you want to copy to.


10

Don't overwrite the Sitecore.Context item with the one you are fetching for the wildcard. Keep the wildcard item as the context item. Instead, put the product item in a sort of wildcard context. You Helix architecture, you can put this in a foundation project. public static Item WildcardContextItem { get => (Item)HttpContext.Current.Items[...


8

You could create a function that checks the fieldtypes.. based on the renderField pipeline, which is executed in the fieldRenderer you should include these types: rich text single-line text text image link general link internal link multi-line text memo date datetime word document integer number That should be the complete list (on a Sitecore 8.1). There ...


8

Every field can be passed through FieldRenderer. The <sc:FieldRenderer> control makes use of the FieldRenderer.Render static method, which can be used on any field. FieldRenderer.Render passes the field through the field rendering pipeline. Whether or not the text in a given field is actually transformed by the field rendering pipeline is an entirely ...


8

The solution that ended up working for me was to use the DeviceDefinition.GetRenderingByUniqueId method with the RenderingReference.UniqueID object: foreach (RenderingReference renderingReference in parentRenderingReferences) { /* ... unrelated code removed ... */ var layoutField = new LayoutField(contentItem.Fields[FieldIDs.LayoutField]); ...


8

The Experience Editor (previously Page Editor) allows you to switch between devices. Also for the Preview mode. Ribbon > Experience > Click on current device > Select preferred device


8

http://jockstothecore.com/defaulting-shared-layout-editing-sitecore-8-1/ A simple setting is not available, but in the blog post above you can find code for a custom processor for the loggedin pipeline that will do the trick. You can still choose on which environments you add the pipeline processor (live only dev). The code itself will set the Registry ...


8

You can get the personalization from the renderings field. If you open an item that contains personalization you will notice on the renderings field in Raw mode something like this: <rls><ruleset><rule uid="{088B27BA-3E2E-4928-9F67-3951C7C0F112}" s:name="test"><conditions><condition uid="7B0698159A914755B99BE5A5D6A0786D" s:id="{...


8

Yes, you can do it by the following way. Configuration: <configuration xmlns:patch="http://www.sitecore.net/xmlconfig/"> <sitecore> <pipelines> <mvc.renderRendering> <processor type="YourAssembly.LogExecuteRenderer, YourAssembly" patch:instead="processor[@type='Sitecore.Mvc.Pipelines.Response.RenderRendering....


7

If you have not already used a base template with presentation, this will be tricky. Normally I would have a base page template with some core presentation elements and then all other page templates would inherit from that - also I try to have very few page templates. For your problem you are probably going to have to add the element to the standard values ...


7

Prepare for a huge wall of text here which is not tested, but should work in theory and is a perfect blog post material :) So the easiest way to do this, is to actually act to the unselectable items in the same way that Sitecore reacts to the unselectable templates - i.e. showing a message and telling that this is not a valid choice. So the first stop ...


7

Rendering parameters are stored in Sitecore as a query string eg: param1=value1&param2=value2 etc.... And this query string is stored as an attribute on an XML node in the __Renderings or __Final Renderings field on the context item, like this: <r uid="{91C058E4-4307-4391-98B2-A7629FF9C729}" p:before="r[@uid='{6717EAA7-0931-46D9-8E89-...


7

You can access the layout in your code by using Sitecore.Context.Item.Visualization.Layout (example for context item). This will give you a LayoutItem that gives you access to the name, physical file, ...


Only top voted, non community-wiki answers of a minimum length are eligible