Are you enjoying the extensions? Did you like the support? Help others decide.

Leave a review

file Date format for Joomla! custom field

More
4 years 1 month ago #5308 by Tomoe
Hi,
I've got a date custom field which is displayed in LNEP view. It's been displayed as "20 octobre 2020" for example, but I would like to show "Mardi 20 octobre 2020". How can I change date format for this custom field only (not for publishing date for example)?
Best regards

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

More
4 years 1 month ago #5309 by syw
Replied by syw on topic Date format for Joomla! custom field
Hi, 

The best way to do this is to override the lnep_detail_jfield_calendar.php layout from the components' details folder.

Then you can change the format in that file. It uses the format set in the extension by default. 

You can test by field Id to set the format per custom field.

It does not affect the standard date fields, which use the lnep_detail_date.php layout.

To learn how you can override the layout, please check the documentation.

Olivier.

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

More
4 years 1 month ago #5310 by Tomoe
Replied by Tomoe on topic Date format for Joomla! custom field
Thanks syw, that's what I done, but adding a "l" in date format didn't change anything 
if ($field_data) { echo '<span class="detail_data">'.HTMLHelper::_('date', $field_data, $params->get('d_format', 'l d F Y')).'</span>';} else {   echo '<span class="detail_data">-</span>';}
I tried to change drastically date format, suppressing "Y" for example, but nothing changed in date. Override is OK because when I add a css class for example, it's displayed in frontend.

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

More
4 years 1 month ago #5311 by syw
Replied by syw on topic Date format for Joomla! custom field
$params->get('d_format', 'l d F Y') retrieves the format that is set in the extension.
'l d F Y' is the default that would be used if there was no value set in the extension.

Therefore, since you want to set a value that is different than the one that is set in the extension, you should not keep $params->get('d_format', 'l d F Y').

Replace 
HTMLHelper::_('date', $field_data, $params->get('d_format', 'l d F Y'))
with 
HTMLHelper::_('date', $field_data, 'l d F Y')

Olivier.

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

More
4 years 1 month ago #5312 by Tomoe
Replied by Tomoe on topic Date format for Joomla! custom field
Thanks Olivier! I wasn't definitely unable to do this by myself. Your explanation is very clear.

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

More
4 years 1 month ago #5313 by syw
Replied by syw on topic Date format for Joomla! custom field
Great! You are welcome :-)

Olivier.

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