So I have some trouble figuring out how to get published content from my "Settings" document type in SettingsController : SurfaceController.
If I do standard hijacking with SettingsModel : RenderModel it gives me my Home document type when using base(UmbracoContext...) Seems logic because I'am calling Html.Action("RenderFooter", "Seetings") from my _Layout view and landing page is Home
So my question is how do I access "Settings" document type and map my custom model with the properties from there? One side note is that I have two published "Settings" document type because I'm doing one tree for english and one for swedish
So how do I know which one to get?
Is it not possible to get published content with SurfaceController?
SettingsController
public class SettingsController : SurfaceController
{
public ActionResult RenderFooter(SettingsModel model)
{
return PartialView("_Footer", model);
}
}
SettingsModel
public class SettingsModel : RenderModel
{
public SettingsModel()
: base(UmbracoContext.Current.PublishedContentRequest.PublishedContent)
{
Links = new FooterLinks
{
Facebook = Content.GetPropertyValue<string>("facebook"),
Twitter = Content.GetPropertyValue<string>("twitter"),
Youtube = Content.GetPropertyValue<string>("youtube"),
Instagram = Content.GetPropertyValue<string>("instagram")
};
ContactInfo = new ContactInformation
{
Name = Content.GetPropertyValue<string>("companyName"),
Street = Content.GetPropertyValue<string>("street"),
Postal = Content.GetPropertyValue<string>("postalCode"),
Phone = Content.GetPropertyValue<string>("phone"),
Email = Content.GetPropertyValue<string>("email")
};
Something = new Something
{
Text = Content.GetPropertyValue<string>("something")
};
}
public FooterLinks Links { get; set; }
public ContactInformation ContactInfo { get; set; }
public Something Something { get; set; }
}
RenderModel in a SurfaceController
So I have some trouble figuring out how to get published content from my "Settings" document type in SettingsController : SurfaceController.
If I do standard hijacking with SettingsModel : RenderModel it gives me my Home document type when using base(UmbracoContext...) Seems logic because I'am calling Html.Action("RenderFooter", "Seetings") from my _Layout view and landing page is Home
So my question is how do I access "Settings" document type and map my custom model with the properties from there? One side note is that I have two published "Settings" document type because I'm doing one tree for english and one for swedish
So how do I know which one to get? Is it not possible to get published content with SurfaceController?
SettingsController
SettingsModel
_Layout
_Footer
When you use route hijacking you need to use RenderMvcController or the IRenderMvcController. The Hybrid Framework shows how the IRenderMvcController can be used with a SurfaceController: https://github.com/jbreuer/Hybrid-Framework-for-Umbraco-v7-Best-Practises/blob/master/Umbraco.Extensions/Controllers/Base/SurfaceRenderMvcController.cs#L14
Jeroen
Thank you Jeroen I have a look at it!
is working on a reply...