Webrocker Posted January 6, 2016 Share Posted January 6, 2016 Hi and Happy New Year to you all I'm currently reviewing some of my first sites, esp. regarding better usability for the backend users/editors. One thing I use often is to set the infos displayed in the tree/listing view, for example have not only the title, but also the category or the published date visible. Now, if the format of the date field is not set in the template settings, this will display the unix timestamp, which is not so comfortable for the editor. But if I set the format, this will influence how the date is displayed in the front end, which may be too inflexible, for example if the field is used in different templates, maybe with a short and a complete date display. I decided to use the unformatted date and format it to my needs in the front end templates. but as said, this makes the backend display of the date unusable for the editor. Now upon revisiting this situation, I wonder if it would be better to use a (pre set) format that's suitable for my back end editors needs, and make a strtotime/strftime formatting in the frond end templates to change the date format if needed. How is your approach to this, or how is the set-date-format at field level thing intended to be used? cheers, Tom Link to comment Share on other sites More sharing options...
LostKobrakai Posted January 6, 2016 Share Posted January 6, 2016 Set the format to a sensible default and use this in the frontend to get the timestamp for other formatting purposes: // 1452082822 $timestamp = $page->getUnformatted("dateField"); // 01/06/2016 12:20 $defaultFormat = $page->dateField; 3 Link to comment Share on other sites More sharing options...
Webrocker Posted January 6, 2016 Author Share Posted January 6, 2016 Ok, I completly managed to miss ->getUnformatted m( thx Tom Link to comment Share on other sites More sharing options...
LostKobrakai Posted January 6, 2016 Share Posted January 6, 2016 It's really useful for that exact use-case, but sometimes it can also be nice when you need to get a field value without textformatters being applied or other kinds of output formatters. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now