If you try to preview content that does not have a template specified, you get the 404 page. I would like to be able to default to a specific template (as opposed to creating a custom 404 page). Is this possible? Some way to hook into the process that looks for a template?
Thanks Jeavon, that's the type of thing I was looking for. I was able to implement what I needed using an "error404" page.
I'm using Umbraco for the back-office only. The web site is hosted on a stand-alone ASP.NET website. When content is published in Umbraco, I push it into Azure blob storage where the ASP.NET web site can use it. This achieves a decoupling of the CMS from the website itself. Theoretically, I could use any CMS and leave the public site completely unchanged. (In fact, I did a proof of concept with SharePoint, but the customer preferred Umbraco, thank goodness.)
Anyway, what I was trying to achieve was to hack the Preview functionality in the Umbraco back-office. I didn't want to have to create templates for all of the different document types. I built one simple "previewer" template and made that the default template. It then redirects the user to preview the content on the actual website (I am keeping drafts separate from published content in blob storage).
contentPreviewer.cshtml:
@inherits UmbracoTemplatePage
@{
var id = int.Parse(Path.GetFileNameWithoutExtension(Request.Url.AbsolutePath));
var item = Umbraco.Content(id);
var itemTag = StringHelpers.RemoveSpecialCharacters(item.Name);
var previewUrl = ConfigurationManager.AppSettings["cea:ContentApiBaseUrl"];
switch (item.DocumentTypeAlias as string)
{
case "contentPage":
previewUrl += "Content/" + itemTag;
break;
}
previewUrl += (previewUrl.Contains("?") ? "&" : "?") + "draft=1";
}
Global default template?
If you try to preview content that does not have a template specified, you get the 404 page. I would like to be able to default to a specific template (as opposed to creating a custom 404 page). Is this possible? Some way to hook into the process that looks for a template?
Hi David,
To do this you you will need to create a IContentFInder to find the content you would like to return. Creating a IContentFinder is documented here.
Can I ask why you would want to do this?
Jeavon
Thanks Jeavon, that's the type of thing I was looking for. I was able to implement what I needed using an "error404" page.
I'm using Umbraco for the back-office only. The web site is hosted on a stand-alone ASP.NET website. When content is published in Umbraco, I push it into Azure blob storage where the ASP.NET web site can use it. This achieves a decoupling of the CMS from the website itself. Theoretically, I could use any CMS and leave the public site completely unchanged. (In fact, I did a proof of concept with SharePoint, but the customer preferred Umbraco, thank goodness.)
Anyway, what I was trying to achieve was to hack the Preview functionality in the Umbraco back-office. I didn't want to have to create templates for all of the different document types. I built one simple "previewer" template and made that the default template. It then redirects the user to preview the content on the actual website (I am keeping drafts separate from published content in blob storage).
contentPreviewer.cshtml:
It's working great!
is working on a reply...