1

I'm wondering if it possible to make it so that the user is able to choose a "Created" time of a site and if nothing is entered, the current time is used.

Is this possible?

John
  • 165
  • 1
  • 1
  • 15

1 Answers1

3

Yes. Add a property to your root page that is a date/time picker. You can then include that in your template. Assuming you're using Umbraco 7 and Razor, you can use the overloaded method of Umbraco.Field to specify an alternate if the field isn't set. For example:

@Umbraco.Field("myDateField", recursive: true, altText: DateTime.Now.ToString())

Will render the field to the page, on ANY page of the site, as it will recursively look up the field from sub-pages of the root page, and should display the current date/time if nothing is entered.

There are a couple of other methods you could use, depending on whether you're using IPublishedContent or dynamic content in your views.

Tim
  • 4,217
  • 1
  • 15
  • 21