Am using controller rendering, I created one model called Footer.cs and it has below properties.
[SitecoreType(TemplateId = "{1044CFB5-2B85-4A8D-9DCC-34764D2AF5B3}", AutoMap = true)]
public class Footer
{
public virtual Item Item { get; set; }
[SitecoreField(FieldName ="Copyright Text First",FieldType = SitecoreFieldType.SingleLineText)]
public virtual string CopyrightTextFirst { get; set; }
[SitecoreField(FieldName ="Copyright Text Last",FieldType = SitecoreFieldType.SingleLineText)]
public virtual string CopyrightTextLast { get; set; }
}
In My Controller:
public ActionResult FooterTemplate()
{
ISitecoreContext ctx = new SitecoreContext();
var model = ctx.GetCurrentItem<Footer>();
return View(model);
}
But, always getting null result, please help me any one.
You can use:
public ActionResult FooterTemplate()
{
ISitecoreContext ctx = new SitecoreContext();
var model = ctx.GetCurrentItem<Footer>(RenderingContext.Current.Rendering.DataSource);
return View(model);
}