I'm trying to create a printer friendly version of a Sitecore page.The first thing I do is add layout for the print device by clicking the "copy to" from the default layout. The layout and all the rendering are copied successfully to the print device. After this, I published the page.
What I am expecting is that, when I add p=1 querystring to the url of the page, it will display the same as the default layout (this is for testing purposes only). But instead, Sitecore encounters an error saying:
> The layout for the requested document was not found
> Requested URL: URL Of The Page
> Requested Layout: {00000000-0000-0000-0000-000000000000}
> Requested Device: Print
Note: SXA is installed to my Sitecore instance
Please let me know what I am missing.
I am using Sitecore 9 by the way.
Did you publish layout and device? I had similar error when layout wasn't published.
The easiest (and the most reliable) way to check is it published is to switch to web DB and check is layout and device are there in content tree.
A bit late for an answer perhaps, but this behavior is intended. The 'Print' device uses the querystring p=1 to display the Print layout. Thing I did to change this behavior is change the 'p=1' to 'print=1' for the print layout.
So, I guess this should be the correct answer ;)!
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
The way that Page Editor handles versions has been causing issues for in one of our Sitecore solutions for a client. I've posted about them here:
Sitecore instance showing incorrect workflow state in Page Editor
Expected usage of Page Editor's Experience date
I didn't get much response on those and so far I've surmised that this is just how Sitecore works. This is less than ideal for our instance, as when publishing restrictions are set, authors don't know which version they're editing which is causing various issues for them.
I'd like to implement a solution(s) to improve the experience provide the following functionality:
Something in the Experience tab that shows the number of the version being viewed.
A button on the Experience tab that resets the Date to the default (this is not simply setting the date to the current date/time, but resetting it to act as it did before a date was manually set).
A custom button in Content Editor which allows an author to open a specific version in Page Editor...set the date automatically when it opens, I guess.
An any one give me some clues on how much of this is possible and where to start?
Thanks.
For the first bullet "Something in the Experience tab that shows the number of the version being viewed", you can add version item in Core database.
Move to "Core" DB in Desktop Mode
Navigate to "/sitecore/content/Applications/WebEdit/Ribbons/WebEdit/Experience/"
Create "Versions" item like this, http://imgur.com/bPEDm7R
Create "Compare" item under "Versions" like this, http://imgur.com/dG8dz2M
The result like this, http://imgur.com/HPu3XAL
The content author can see which version they are using and they can also compare with previous versions.
Using Sitecore 7 - Is there a way I can specify what the placeholder of a template's control will be based on device?
Example : Placeholder A if the device is Mobile else Placeholder B
This is more to do with positioning the content differently in Mobile than desktop site.
UPDATE
Trayek's answer is great and would sure work. Although, I ended up using a different approach.
In the layout details of my template, I added a control C; set its placeholder as A and added HideBydevice Desktop in the additional Parameters section. Then, I again added control C; set its placeholder as B and added HideBydevice Mobile in the additional Parameters section.
Then in my code, I check HideBydevice parameter's value and hide the sublayout/control, if the parameter's value is the same as Sitecore.Context.Device.Name
This worked for me.
What you can probably do is use Sitecore's Rules Engine, where you can create (or use a pre-existing) Condition to find out whether you are on a mobile device (to do this, you could use the Mobile Device Detector for instance - although I don't know if that module is supported on Sitecore 7).
Then, you can also use the Action Set placeholder to value.
You could also create your own Action instead, of course. All you'd have to do is get the RenderingReference and simply change the placeholder like so:
var reference = new RenderingReference(this.RenderingID);
reference.Placeholder = "A";
More on this in the Rules Engine Cookbook
Update
I've written a blog post about how to get this done: Read it here.
I've created aliases for the home page of one of the local sites (and it's child pages) in my national website - and I can't figure out how this is happening.
When someone lands on a local page, I have a control (cs file) that creates the local links (to the child pages) on the left hand side of the local web page. These links are derived from the Sitecore context (current item's content path).
After I created the aliases for all of the pages in a local site, that's when I noticed this problem. If the URL is a Sitecore alias, the navigational links are built for the child aliases - otherwise they are resolved by the Sitecore LinkManager, just as they were before the aliases were created. However, when I hit a page for the original local item (not the alias), the links are being rendered for the alias:
childLink.NavigateUrl = LinkManager.GetItemUrl(child);
And I've verified that the child item is valid. Does anyone have any suggestions as to why the LinkManager would be rendering the links for the aliases - and how this can be avoided?
Sitecore.Links.LinkManager.GetItemUrl(item) returns the path to the original item, not the alias path. If you have special logic to identify aliases, for example by using the Sitecore.Context.RawUrl property, you may be running into an issue with output caching, which could be causing the alias version of the control to be displayed when you navigate to the original item.
Update: I'm pretty sure you are running into an output caching issue. I was able to reproduce this behavior by creating a test control, which displays a timestamp and the RawUrl, and by turning on output caching for the control in Presentation Details.
The first time the control is displayed, whether it is for the item or the alias, the output is cached, and this cached output is displayed each time the control is viewed, either for the original item or the alias. Even if you switch on "Vary By Data", the effect is the same, because "Vary By Data" is driven by the Data Source item, not the URL.
To fix this behavior, you need to add the cached state to the output of the GetCachingId property:
protected override string GetCachingID()
{
return this.GetType().Name + (IsAlias() ? "Alias": "Item");
}
private bool IsAlias()
{
return Sitecore.Context.Database.Aliases.Exists(Sitecore.Context.RawUrl);
}
Props to this answer for the IsAlias logic.
In this case, wheter or not the Alias will be given relies on a setting in the web.config.
If the LinkManager has the option "ApplyAliases" (Whether or not to check for and apply aliases when possible) set to true, the LinkManager will return aliases when possible.
You can read more about configuring your LinkManager, and overriding certain settings in codebehind on this blog page written by John West.
Good luck!
I'm busy writing a sitecore solution to manage a news site. I have a NewsArticleLayout (used to display a NewsArticle item), with a NewsArticleMailPlaceholder which I want to use to display a form where a user can enter a name and email address where a news article link must be mailed to.
On the NewsArticleLayout page is already a NewsArticleSublayout with a phNewsArticle placeholder, which is currently correctly displaying data related to a news article.
When I try to link the form to this placeholder, I only seem to be able to link to placeholders in sublayouts, not in layouts, so I created a MailNewsArticleSublayout, and placed a phMailNewsArticle placeholder on it. Then I told the form to display on the NewsArticleLayout, using the MailNewsArticleSublayout, and the phMailNewsArticle placeholder.
However, when I view the page, my form doesn't display. I've done a full publish of my entire Sitecore content tree, nothing seems to fix it.
I've even added a phEmail placeholder to the NewsArticleSublayout, and linked this to the form layout details, but this also doesn't display anything.
Have I correctly setup my form's layout? Is there something I'm missing here?
After speaking to sitecore support, I was able to resolve the issue. What I was missing was adding "Form" to the layout details on the standard values for my template. Then in this Form element, fill in the actual Form's location in the "FormID" field. After adding this, it worked perfectly.