This project is read-only.

Host HTML templates for external services

Topics: General, Writing modules
Oct 23, 2014 at 8:46 AM
Is it possible to host simple static (non-themed!) HTML files in orchard? Using custom URLs (like /templates/mytemplate/), and having the ability to replace theme on-the-fly without having to deploy again?

Is it possible to host internationalized versions of these files (using the handy @T("") function in the content)? While keeping the possibility to edit them from the admin?
Oct 25, 2014 at 12:12 AM
I'm not entirely sure what you want to achieve but you can add the Themed(false) attribute to a controller to prevent the theme from getting around it. Then it's plain MCV: you can build the whole layout from your own templates.
Oct 29, 2014 at 5:10 PM
Edited Oct 29, 2014 at 5:11 PM
I know about the controller's themed attribute. I'm talking about basic CMS functionality here, so a file an orchard contributor could update from the admin without having to deploy the website again each time he wants to make a modification. I used to do this when I worked with SharePoint by uploading a page in a document library without basing it on a masterpage or page layout.

Versioning is not needed in our case.

The purpose would be to let our site admins create and maintain a small tutorial on how to use an in-site web application, or to centralize and host the email templates used by our application's web services tier.

The internationalization capabilities would only be a handy additional functionality, as we could at worst maintain separate static files in different culture folders (and point to the correct URL based on user culture).
Oct 30, 2014 at 2:06 AM
You can host static HTML files, but you won't be able to use things like @T(""), since your file would be, well, static.
To host static files, simply create your folder anywhere you like, and make sure to include a web.config file that adds a static file handler (look at web.config in existing folders such as Scripts and Styles in one of the modules).
Oct 30, 2014 at 9:35 AM
Edited Oct 30, 2014 at 9:36 AM
Well, this would imply deploying the website to modify any of the files on the Azure server. And this would require full admin privileges, site down-time for deployment, a valid version of visual studio on the contributor machine... you see where I am going?

We need to manage these files from the back-end, not as a deployment file! Like it's done with pictures in the media library (which we could also use to host html files, but it's really not handy because it was designed for... media files).

The important point in my question is not the "static file" part (the title of this thread was poorly chosen) but the "unthemed and manageable from the admin" part. The "static file" part is here because I thought it would be the only way to achieve this (can't let contributors write dynamic snippets in their pages...).
Oct 30, 2014 at 7:26 PM
I see. Well, there's nothing that let's you do this out of the box, but definitely possible with a custom module. This module could either provide all of the desired features itself, or plugin into the Media Library, defining a specific HTML media type, and an editor to edit the contents (CodeMirror comes to mind).
Oct 30, 2014 at 7:28 PM
Actually, I might be wrong: you could define a custom content type and attach the DisableThemePart. This way, you can let your users manage static HTML, have routes to these content items, and they would render without the theme.
Nov 7, 2014 at 9:58 PM
Edited Nov 7, 2014 at 9:59 PM
I think I would also need to redefine the content type template as the default one includes an <article> tag surronding the body content (and the creation date is also displayed in the html). But that seems like a good starting point.