Problem in displaying correctly date format

  • Posts: 26
  • Thank you received: 0
9 years 6 months ago #231695

-- HikaShop version -- : 2.6.0
-- Joomla version -- : 3.4.5

Hi,

We've got a problem in displaying correctly a date format on front-end.
Our goal is to display a date (previously inserted in the product details) on a category display, namely "listing_img_desc.php". We are displaying the custom field with this code:

<?php echo $this->row->datacalendario; ?>

Initially, in admin, we chose to create a "Simple date picker" custom field, but we read the alert suggesting to use the "Advanced date picker" in order to change date format.

We switched from "Simple date picker" to "Advanced", but the result is as you can see in the attachment: "Front-end.jpg".
As you can see, in the first box, named "Il rischio di esporsi alla vita", there's still the date format inserted with the "Simple date picker", but in the second, "Omelia Natale 2015", there's the value inserted in the "Advanced date picker", and displayed "20151225000000" instead of "25/12/2015".

The date format we inserted in the "Advanced date picker" custom field is: %d-%m-%Y.
In the preview section of the custom field, and in the product details (in admin) it displays correctly, but not on front-end.

Thank you

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 84328
  • Thank you received: 13718
  • MODERATOR
9 years 6 months ago #231696

Hi,

Your code only display the raw data of the custom field. You need to use the custom fields class display function so that it converts it using the settings of your custom field, like with the example I gave here:
hikashop.com/forum/product-category-disp...r-plugin.html#159385

Please Log in or Create an account to join the conversation.

  • Posts: 26
  • Thank you received: 0
9 years 6 months ago #231829

Hi,

Thank you for your answer. I tried the solution provided in the thread.
I've inserted this code, in my <span>:

<span class="product_date">
<?php $fieldsClass = hikashop_get('class.field);
$fields = $fieldsClass->getFields('frontcomp',$this->row,'product','checkout&task=state');
echo $fieldsClass->show($fields['datacalendario'],$this->row->datacalendario); ?>
</span>
Surely i've done something wrong, 'cause now i'm getting this parse error:
Parse error: syntax error, unexpected T_STRING in /web/htdocs/www.romena.it/home/templates/wt_churchy/html/com_hikashop/product/listing_img_desc.php on line 131

Please Log in or Create an account to join the conversation.

  • Posts: 84328
  • Thank you received: 13718
  • MODERATOR
9 years 6 months ago #231839

Hi,

There's a typo.
The line:
$fieldsClass = hikashop_get('class.field);
should be:
$fieldsClass = hikashop_get('class.field');

The following user(s) said Thank You: edizioniromena

Please Log in or Create an account to join the conversation.

  • Posts: 26
  • Thank you received: 0
9 years 6 months ago #231988

Thank you! Now it works like a charm!

Please Log in or Create an account to join the conversation.

  • Posts: 26
  • Thank you received: 0
9 years 6 months ago #231995

Hi,

Thank you again for your answer, i've got another question: is there a way to insert a date picker, in my front-end, that allows the user to select a date to search in my "datacalendario" field?
I'm creating a set of filters (through the Hikashop filter section) to allow a filtering of my products. I'd like to insert a date picker to search in the "Advanced date picker", named "datacalendario", custom field that i've created.

Please Log in or Create an account to join the conversation.

  • Posts: 84328
  • Thank you received: 13718
  • MODERATOR
9 years 6 months ago #231997

Hi,

The filter system doesn't handle dates. So it won't work with what's there by default.
It would require creating your own search module with your own results display to achieve that.
It's not impossible, but it will be a lot of work, even for a developer.

Please Log in or Create an account to join the conversation.

  • Posts: 26
  • Thank you received: 0
9 years 6 months ago #232116

Ok, thank you.

Please Log in or Create an account to join the conversation.

Time to create page: 0.078 seconds
Powered by Kunena Forum