jDownloads Support Forum

Older Versions => jDownloads 3.2 (Support ended) => General => Topic started by: Miek on 24.10.2016 21:04:30

Title: Date format custom field doesn't work
Post by: Miek on 24.10.2016 21:04:30
Hello,

I am new to JDownloads and am testing local on Xampp to get the layout right before moving it to my live site. Been trying all day now to solve a problem with the custom date field.

I need to use that field because I don't want to display the created or modified date of a file. I need the user to pick a date because the files are presentations which usually are uploaded several days after the day of presentation.

I found the downloads.xml file uploaded for someone with the same problem, but I can't get it to work. Tried it at first as a template override, but that doesn't change anything. Tried to modify the file in the components folder. That seemed to work, but when I try to save my upload (frontend), I get this error message on a blank screen:
0 - DateTime::__construct(): Failed to parse time string (11 oktober 2016) at position 0 (1): Unexpected character

Searched the forum and the internet, but I can't find what causes it, nor a solution.
In the configuration I did set long date to l d F Y. I have also made a Joomla language override for LC2 to the same format. I would like to have all dates throughout the site in this format, so I would very much like to see this solved.
Anyway, I really love the component because it's extremely user friendly in frontend uploading!
Miek








Title: Re: Date format custom field doesn't work
Post by: Arno on 24.10.2016 23:37:59
Hi,
i do not understand what you have tried exactly.

At first should you read this in the documentation:
http://www.jdownloads.net/documentations/item/using-custom-fields

In your case must you use a date custom field. Or have you try this already?
Title: Re: Date format custom field doesn't work
Post by: Miek on 25.10.2016 00:23:37
Yes, I read the documentation. I made a custom field, field 11, but I want it not to show 2016-10-11 format but 11 october 2016 instead. Therefore I used your solution within the downloads.xml file in adding a date format. But it doesn't work because I get this error message.

It works in the form, but whenever I try to save I get this error.

Believe me, I tried every solution I could think of, but I cannot make the date show as I want it.

Miek
Title: Re: Date format custom field doesn't work
Post by: Arno on 25.10.2016 01:57:26
Okay.

Open the download.xml and change the custom_filed_11 field as you can see on the pic below.
The result can you see on the other pic.

Read here all possibilities for a calendar field:
https://docs.joomla.org/Calendar_form_field_type

By the way, the custom_field_11 is created in the file jdcustomfield11.php in the backend path /models/fields/.


[gelöscht durch Administrator]
Title: Re: Date format custom field doesn't work
Post by: Miek on 25.10.2016 08:52:46
Yes, that's wat I did in the first place. But that is giving me the parse error which I can't solve.... :'(
Title: Re: Date format custom field doesn't work
Post by: Arno on 25.10.2016 12:06:44
Hm... you have right. I get not any error but the date is not stored in the db table. Seems that it must be converted first. I had never tried the format option until today. But i will see what is to do.  ::)
Title: Re: Date format custom field doesn't work
Post by: Miek on 25.10.2016 12:22:41
O, great! My knowledge  of PHP  doesn't reach that far,  so I appreciate your help in this  matter!   
Title: Re: Date format custom field doesn't work
Post by: Arno on 25.10.2016 13:19:09
To use date in different formats is not so an easy thing. The  format in the database is always 'datetime' ('0000-00-00 00:00:00'). So it must be converted before we can store inputs in another formats.

Please try the fast created 'fix' below and copy the unzipped file to: administrator/components/com_jdownloads/tables/
(But you must have the newest version 3.2.46 installed.)

Try it then again.




[gelöscht durch Administrator]
Title: Re: Date format custom field doesn't work
Post by: Miek on 25.10.2016 14:20:27
Thank you for your  quick reaction! I shall  test it tonight  because  I'm  not at home right  now. ..

Title: Re: Date format custom field doesn't work
Post by: Miek on 26.10.2016 00:30:00
Hello Arno,

I'm sorry to have to tell you the fix doesn't work. The error message is gone, but the date with format l d F Y  still isn't saved in the database. I checked, all zero's in the table of custom field 11 or12. :'(

Title: Re: Date format custom field doesn't work
Post by: Arno on 26.10.2016 01:19:48
You have used a invalid format. Use this: format="%A %d %B %Y"
and you should  get this from the pic (also stored in the db).

See description here:
https://docs.joomla.org/Calendar_form_field_type

[gelöscht durch Administrator]
Title: Re: Date format custom field doesn't work
Post by: Miek on 26.10.2016 12:28:21
For me this doesn't work. Can't find out why not.

This is what I have done so far:

1. changed the download.xml according to your instructions
2. copied the new download.php to the right directory
3. made a files layout with the custom field 12 in it
4. put that field in the form for registered users

When filled in the field shows the right date format. But saving results in an empty field on frontend and a 0000-00-00 field in the database.

When I make the date field mandatory it turns red when it is filled in according the new format, but anyway I am allowed to save and the record is saved with all except the date.

If I use the standard field file date everything works, so that could also be an option for me, but this field has a calender icon in front of it which I don't want, but I haven't located it yet, so I don't know how to remove it. But thinking of it, this might be a much more easy way to solve my problem...

The attachments are screenshots of my steps.

Thank you for your efforts in helping me!







[gelöscht durch Administrator]
Title: Re: Date format custom field doesn't work
Post by: Arno on 26.10.2016 12:43:53
Hm... strange.
You edited the Download in the frontend, correct?
But why have you added this line?
size="22"
I think this is the reason for your problem. Remove it and try it again.
Title: Re: Date format custom field doesn't work
Post by: Arno on 26.10.2016 12:58:16
Remove also the user_utc line.
Title: Re: Date format custom field doesn't work
Post by: Miek on 26.10.2016 15:54:07
I'm sorry, I give up on this one. Can't get it to work.

I'll use file_date instead. That is working fine. Found the setting for the mini icons in the backend and now its looking just the way I want. :)

Thanks
Title: Re: Date format custom field doesn't work
Post by: Arno on 27.10.2016 11:11:58
For me works the date (as described) properly. But okay, the mean thing is that you have found a solution.  ;)