- Posts: 78
- Thank you received: 5
Custom Field needs proper formatting
- brentwilliams2
-
Topic Author
- Offline
-- Joomla version -- : 2.5.27
I am trying to insert a custom field within a product page. I found that I can show the custom field with this code:
However, it does not format the date correctly. (I am using the Advanced Date Picker)
Can you tell me what code I should use to show the field, "eventdate" properly formatted?
Thanks!
Please Log in or Create an account to join the conversation.
The returned information is a timestamp, so you need the php date() function to format it
php.net/manual/fr/function.date.php
Something like:
Please Log in or Create an account to join the conversation.
- brentwilliams2
-
Topic Author
- Offline
- Posts: 78
- Thank you received: 5
On a test product, the date in the database shows "20150226000000". I had originally entered February 26, 2015, so the database appears to show correctly.
But when I implement the code you gave, it shows "30-Mar-640505". So something isn't translating right...
Please Log in or Create an account to join the conversation.
While the simple date picker is using a timestamp, the advanced date picker store the date in an internal format.
The internal format has been choose to let everybody select a date before 1 January 1970 (otherwise we can't be sure that the saved time-stamp will work right on every servers) and also to simplify some algorithms of date restriction.
That's why it's better to use the HikaShop field class to display the custom field, so the advanced date picker plugin will process itself the value and display the date with an appropriate format.
Otherwise, you can use the code of the function "getDate" (convert text into an array) and "getTimestamp" (convert an array into a timestamp) of the plugin in order to convert the value.
Regards,
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Please Log in or Create an account to join the conversation.
- brentwilliams2
-
Topic Author
- Offline
- Posts: 78
- Thank you received: 5
Am I implementing incorrectly? It is in the show_default.php.
Please Log in or Create an account to join the conversation.
- brentwilliams2
-
Topic Author
- Offline
- Posts: 78
- Thank you received: 5
Please Log in or Create an account to join the conversation.
Yes, it is exactly what I was talking about in my answer.Am I implementing incorrectly? It is in the show_default.php.
That's why it's better to use the HikaShop field class to display the custom field, so the advanced date picker plugin will process itself the value and display the date with an appropriate format.
Regards,
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Please Log in or Create an account to join the conversation.
- brentwilliams2
-
Topic Author
- Offline
- Posts: 78
- Thank you received: 5
That's why it's better to use the HikaShop field class to display the custom field, so the advanced date picker plugin will process itself the value and display the date with an appropriate format.
Can you point me to the instructions on how to do this or show me an example?
(By the way, I wanted to say how much I appreciate your help, and I apologize that I'm not "getting it". Sorry for not understanding your instructions.)
Please Log in or Create an account to join the conversation.
Please check your PHP error log.
Without more details bout the fatal error you got it will be difficult to tell you more.
But the approach is for me the right one.
Regards,
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Please Log in or Create an account to join the conversation.
- brentwilliams2
-
Topic Author
- Offline
- Posts: 78
- Thank you received: 5
Fatal error: Call to undefined method hikashop::show() in C:\xampp\htdocs\administrator\components\com_hikashop\classes\field.php on line 1298
Please Log in or Create an account to join the conversation.
What does the variable "$fields" contains ?
As you see in the "show" function in the HikaShop field class ; it asks for specific data.
Regards,
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Please Log in or Create an account to join the conversation.
- brentwilliams2
-
Topic Author
- Offline
- Posts: 78
- Thank you received: 5
All I know is that my custom field is "eventdate" in the database and is a product field, and based upon the example provided in the other link, it looked like this was the format of the code I was supposed to use, although I don't know if that is true.
Beyond that, I simply don't know how this bit of code works. If there is another piece of code that will allow me to use a custom field elsewhere in a template, I would be happy to use it. I just don't know of any other option, and I don't know how to answer your question.
Please Log in or Create an account to join the conversation.
The example code I gave in the other thread is correct and the code you're using is correct too.
So it must come from something else.
First, try to update HikaShop to the latest version. Make sure that the Hikashop Date Picker Plugin of the "hikashop" group is enabled via the joomla plugins manager.
If that doesn't help, please provide a screenshot of the options of the custom field so that we can see how you configured it.
Please Log in or Create an account to join the conversation.
- brentwilliams2
-
Topic Author
- Offline
- Posts: 78
- Thank you received: 5
Please Log in or Create an account to join the conversation.