Keyword

Display age in the present

  • saovry
  • saovry's Avatar Topic Author
  • Offline
  • Senior Member
More
3 years 2 months ago #178100 by saovry
Display age in the present was created by saovry
I have a question about Extract Field date on K2..

the Field of Date, user select the date and it can show the age.

Do you have any code of it?

If ueser select 10/02/2010, so the result will display " 11 Years OLd and 03 months"

thank..

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

More
3 years 2 months ago - 3 years 2 months ago #178116 by JoomlaWorks
Replied by JoomlaWorks on topic Display age in the present
Run this check in the foreach loop that prints out the extra fields:
<?php if($extraField->type == 'date'): ?>
This is the raw date value to format as you like >> <?php echo $extraField->rawValue; ?>
<?php endif; ?>

Then use PHP date formatting (www.php.net/manual/en/function.date.php) to render rawValue; ?> to anything you like.

Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Last edit: 3 years 2 months ago by JoomlaWorks.

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

  • saovry
  • saovry's Avatar Topic Author
  • Offline
  • Senior Member
More
3 years 2 months ago #178139 by saovry
Replied by saovry on topic Display age in the present
Sorry, could you give me a little more guide..

Where could I pass this code into?
Where could I overwrite it when I update K2 so the code still in there. The code will lost..

thank u..

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

More
3 years 2 months ago #178151 by JoomlaWorks
Replied by JoomlaWorks on topic Display age in the present
If you know basic PHP coding, it should not be an issue for you to find the extra fields foreach loop and modify it to get the raw date value. If you need more explaining, then what you ask is beyond the support provided in this forum.

Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

  • saovry
  • saovry's Avatar Topic Author
  • Offline
  • Senior Member
More
3 years 1 month ago - 3 years 1 month ago #178360 by saovry
Replied by saovry on topic Display age in the present

Fotis wrote: If you know basic PHP coding, it should not be an issue for you to find the extra fields foreach loop and modify it to get the raw date value. If you need more explaining, then what you ask is beyond the support provided in this forum.


Dear Fotis,
If you don't mind, could you tell me which files that I need to go working on because I don't know files location and files's name that I need to work on them.
It is my first time that I customize the code and I don't know about the files name/location.

I tried to go component/k2 (There are many folders and files here.)

If I want to display age with these link which files and location.. Could you share with me...
khmercdp.org/index.php/component/k2/item/314-khm0060494
khmercdp.org/index.php/component/k2/itemlist/category/6-khm006

thank
 
Last edit: 3 years 1 month ago by saovry.

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

More
3 years 3 weeks ago #178428 by JoomlaWorks
Replied by JoomlaWorks on topic Display age in the present
Create a set of K2 template overrides inside your current Joomla template. Follow this guide: getk2.org/documentation/tutorials/templating-with-k2-and-the-concepts-of-sub-templates

Then all you have to do is work on the default/item.php file AFTER you've created any relevant extra fields of course (so you have the data to work with).

Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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


Powered by Kunena Forum