- Posts: 11
COMMUNITY FORUM
Edit EXTRA FIELD DATE format in specific template
- Bruno
- Topic Author
- Offline
- New Member
Less
More
10 years 3 months ago #130924
by Bruno
Edit EXTRA FIELD DATE format in specific template was created by Bruno
Hi there
would it be possibel to edit the extra field date output for a single (specific) template?
in this case i have the pre-formated date: (eg:) Monday, 21 June 2014
i would like to take out the week day, but only for this template;
i read about this but it was for k2 entire date format, not for extrafield date, nor for a specific template..
any ideas to fix this?
thanks in advance
Bruno
would it be possibel to edit the extra field date output for a single (specific) template?
in this case i have the pre-formated date: (eg:) Monday, 21 June 2014
i would like to take out the week day, but only for this template;
i read about this but it was for k2 entire date format, not for extrafield date, nor for a specific template..
any ideas to fix this?
thanks in advance
Bruno
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
- Offline
- Platinum Member
Less
More
- Posts: 15920
10 years 3 months ago #130925
by Krikor Boghossian
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by Krikor Boghossian on topic Re: Edit EXTRA FIELD DATE format in specific template
Sorry but the extrafield uses the default format.
You can change the other dates in your template or use a text input instead.
You can change the other dates in your template or use a text input instead.
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- Joe Campbell
- Offline
- Platinum Member
Less
More
- Posts: 438
9 years 7 months ago - 9 years 7 months ago #143550
by Joe Campbell
Replied by Joe Campbell on topic Edit EXTRA FIELD DATE format in specific template
Hi Bruno,
The solution that I was able to figure out requires Hacking K2 (which I know is not the best thing - so if anyone knows of a solution that does not require a hack - please provide it)
Background:
The K2 Date Extra Field use the K2_DATE_FORMAT_LC to format the date. Which would then require a site-wide Language Override. But what if you only want to format the date for one or a few specific date extra fields, well this is what you need to do.
Open File:
/components/com_k2/models/item.php
Find Code:
Replace With:(this date format simply removes the comma after the day - making it easy to modify later)
Now in your template override file, you can convert the Extra Field Date with the following code:
I hope this helps,
Joe Campbell
The solution that I was able to figure out requires Hacking K2 (which I know is not the best thing - so if anyone knows of a solution that does not require a hack - please provide it)
Background:
The K2 Date Extra Field use the K2_DATE_FORMAT_LC to format the date. Which would then require a site-wide Language Override. But what if you only want to format the date for one or a few specific date extra fields, well this is what you need to do.
Open File:
/components/com_k2/models/item.php
Find Code:
$value = JHTML::_('date', $value, JText::_('K2_DATE_FORMAT_LC'), $offset);
Replace With:
$value = JHTML::_('date', $value, JText::_('l d F Y'), $offset);
Now in your template override file, you can convert the Extra Field Date with the following code:
<?php
$k2extrafielddate = DateTime::createFromFormat('l d F Y', $this->item->extraFields->ALIASNAME->value);
$new_date_format = $k2extrafielddate ->format('l d F Y'); //specify desired date format
echo $new_date_format;
?>
I hope this helps,
Joe Campbell
Last edit: 9 years 7 months ago by Joe Campbell.
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
- Offline
- Platinum Member
Less
More
- Posts: 15920
9 years 7 months ago #143572
by Krikor Boghossian
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by Krikor Boghossian on topic Edit EXTRA FIELD DATE format in specific template
This looks really nice Joe, Well Done :)
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- Joe Campbell
- Offline
- Platinum Member
Less
More
- Posts: 438
9 years 7 months ago #143587
by Joe Campbell
Replied by Joe Campbell on topic Edit EXTRA FIELD DATE format in specific template
Thanks Krikor - it took a lot of trial & error as I am not a coder (proof that you do not have to be a super coder to make a super Joomla website)
Please Log in or Create an account to join the conversation.
- JoomlaWorks
- Offline
- Admin
Less
More
- Posts: 6218
9 years 6 months ago #143803
by JoomlaWorks
Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by JoomlaWorks on topic Edit EXTRA FIELD DATE format in specific template
Noted for consideration in the next update. Thank you Joseph.
Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- Ronny Van Der Borght
- Offline
- Senior Member
7 years 5 months ago #162415
by Ronny Van Der Borght
Replied by Ronny Van Der Borght on topic Edit EXTRA FIELD DATE format in specific template
An other workaround that does not need a core file change could be a str_replace on the extra field value
$newdate = str_replace(array("monday, ","tuesday, ","wednesday, ", "thursday, ","friday, ","saturday, ","sunday, "), "", $this->item->extraFields->Date->value);
This would change 'monday, 1 march 2017' into '1 march2017'
Same can be done for months etc..
$newdate = str_replace(array("monday, ","tuesday, ","wednesday, ", "thursday, ","friday, ","saturday, ","sunday, "), "", $this->item->extraFields->Date->value);
This would change 'monday, 1 march 2017' into '1 march2017'
Same can be done for months etc..
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
- Offline
- Platinum Member
Less
More
- Posts: 15920
7 years 5 months ago #162424
by Krikor Boghossian
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by Krikor Boghossian on topic Edit EXTRA FIELD DATE format in specific template
Thank you Ronny :)
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.