AI OnAI Off
Hi roYal,
I Don't think you can do this like that, what can you do to add this to your controller not to model file and show it on cshtml after adding,
// in model
[Ignore]
public DateTime DateReminder { get; set; }
// in controller
currentPage.DateReminder = currentPage.DateReminder;
// in cshtml
@{
adding both in variable and show it.
}
thank you
Thank you for answering PuneetGarg.
As I understand it, I have to create a widget if I want to display a property value in edit mode.
Otherwise I have to present the value in the view instead of in the edit mode?
I saw in the settings tab where published date shows as the image below, is it complicated to manage?
Thanks.
I sorted it out.
Created a new Initialization class
[InitializableModule]
[ModuleDependency(typeof(EPiServer.Web.InitializationModule))]
public class EventInitialization : IInitializableModule
{
public void Initialize(InitializationEngine context)
{
ServiceLocator.Current.GetInstance<IContentEvents>().LoadedContent += eventRegistry_LoadedContent;
}
public void Uninitialize(InitializationEngine context)
{
ServiceLocator.Current.GetInstance<IContentEvents>().LoadedContent -= eventRegistry_LoadedContent;
}
void eventRegistry_LoadedContent(object sender, ContentEventArgs e)
{
if (e.Content is MyPageData s)
{
s = s.CreateWritableClone() as MyPageData;
s.DateReminder= s.Changed.AddMonths(p.MonthReminder);
e.Content = s;
}
}
}
Then add the DateToRemind property in you Model to display the new date.
public virtual DateTime? DateReminder{ get; set; }
Done
I thought this would be an easy task but im stuck.
In my model I created a simple MonthReminder property.
Nothing fancy and works fine but then I want to display the Changed date + the MonthReminder somewhere on the page.
With Changed date I mean the built in property that epi sets when modifiy the page
I tried this but don´t show anything on the page.
I do not even manage to show a value on the page, either MonthReminder or Changed by it´s own.
We use EpiServer 11.
Thanks.