Jump to content

Best way to check if datefield has value set


apeisa
 Share

Recommended Posts

Currently yes. :) But I think you just pointed out something kind of silly in PW's date field. If it's not set, it's going to return a date in 1969 (the first date tracked by a unix timestamp). That's not what we want. I just committed an update that makes it return a blank string if there is no date value set. So once you get the latest commit, you can do this:

if($page->startdate) echo $page->startdate;

Or you can just echo the startdate and expect it'll be blank if nothing's been set there. 

There have been a lot of commits in the last few days, so if you haven't updated already, give everything a good test before updating your live sites. Though I don't expect there are any potential problems, but I'm always a little overcautious any time I push a lot of new code to the repo. 

Link to comment
Share on other sites

I also stumbled over this , I did use a date field as label in the advanced template setting, if not filled it showed 1.1.1970 in the page tree if I remember correctly... Now it's cool it show nothing if date isn't set.

Speaking of the tons of commits you did, I especially like the new template label field... was kinda wondering already why there's none. Wouldn't it make more sense to name it Description, I think it could be mixed up with the templates labels in the page tree?

Link to comment
Share on other sites

Speaking of the tons of commits you did, I especially like the new template label field... was kinda wondering already why there's none. Wouldn't it make more sense to name it Description, I think it could be mixed up with the templates labels in the page tree?

Not sure I understand what you mean about the templates labels in the page tree?

But the reason for the name 'label' is for consistency with the 'label' and 'description' used by Fields. In PW, 'description' means something that can either be any length, short or long. Whereas 'label' is implied to be short (word or phrase) just like the English dictionary meaning.  We want the template labels to be short so they can be used in select boxes and the like. This also leaves room for us to add a 'description' field to templates down the road (should we want it) that would be consistent with the same thing from Fields.

Technically template labels aren't really necessary except in a multi-language situation. So PW will likely keep the label field collapsed by default and one can utilize it if they want to.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...