I'm wondering if it possible to make it so that the user is able to pick a "Created" time of a site and if nothing is entered, the current time is used.
As Tim said you can use a date picker on your document type, with time or not, and then check if the date picker has a value. If not then you can use the create date as fallback value.
To get the date from a date picker you can use this code.
I tried that code, but not when a specific date in inputed, the date is not showing. Only pages that has the default current time is displaying its current date. The custom date is not displaying. Do you know what could be the problem?
Edit "created" date and time
I'm wondering if it possible to make it so that the user is able to pick a "Created" time of a site and if nothing is entered, the current time is used.
Is this possible?
Comment author was deleted
You could add an additional property to the doc type... and if that is populated use that , if it isn't use the default create date
But how can I make it so that it uses the doc type instead of the default in "created"?
Hi Johan,
As Tim said you can use a date picker on your document type, with time or not, and then check if the date picker has a value. If not then you can use the create date as fallback value.
To get the date from a date picker you can use this code.
For the date picker with time you should be able to do something like this.
Remember to change the alias of date so it match your alias for your date picker.
Hope this helps,
/Dennis
Comment author was deleted
On your frontend? Well in your views you can just output what you want...
I tried this in my homepage but it didnt work..
Hi Johan,
Try change the @CurrentPage in the foreach loop to @page. So your code looks like this.
When you are in a foreach loop, the the variable is now refers to the current page.
Hope this helps,
/Dennis
Your
OrderBy
doesn't seem correct.Try using it as lambda call:
OrderByDescending(x => x.CreateDate).Take(5)
Hi Dennis,
I tried that code, but not when a specific date in inputed, the date is not showing. Only pages that has the default current time is displaying its current date. The custom date is not displaying. Do you know what could be the problem?
Hi Johan,
First, try to change:
to
Also make sure that the page that you are looping over has a date picked in the page.
Hope this helps,
/Dennis
Hi Dennis,
For some reason this
@page.date.ToString("dd MMM yyyy")
doesnt seem to work.Only the ones that doesn't have a picked date shows the current date.
The page that has a picked date by the user doesnt show the date.
The
@page.date.ToString("dd MMM yyyy")
doesn't seem to work. Are you sure it's correct code?Hi Johan,
Oh now I see why :- )
This @page.date.ToString("dd MMM yyyy") needs to be:
Hope this helps,
/Dennis
Thank you :)
How can I order by that?
this code only orders by the default createDate, how can I make it so it orders by both the date picker and the createDate?
Try to do something like this
What this will do is first sort by the publiceringstid, and then by createDate
Will this work for you?
/Dennis
Well it works by that it first sort by the publiserigstid and then createDate, but I need to sort by for both at the same time..
Is there any way to do this?
Hi Johan,
I don´t think it´s possible to sort on two properties at the same time. You need to sort at one property and then another.
/Dennis
is working on a reply...