Is there a smarty short code for displaying age of listing.
eg: if the listing was listed an hour ago it will say 1 hour.
Thanks
Is there a smarty short code for displaying age of listing.
eg: if the listing was listed an hour ago it will say 1 hour.
Thanks
Hello Niall,
Smarty doesn't have such modifier by default but I found some solutions in the web:
- https://github.com/nZEDb/nZEDb/blob/...er.timeago.php
- https://gist.github.com/dodyrw/4943269
- http://www.smarty.net/forums/viewtopic.php?p=61841
You should create file (modifier) in this dir: /libs/smarty/plugins/modifier.MODIFIER_NAME.php
and past the modifier code from the sample to the file. After that you may use the modifier as:
{$listing.Date|MODIFIER_NAME}
I hope it was clear explanation, let me know if not.
John
I like where you going with this
http://www.smarty.net/forums/viewtopic.php?p=61841 seems to be the best option but Im lost on how to implement this ie how does the modifier script know the age of the listing... Could you please please please help me out on this one. Im sure you could use this feature in your next update.
Sorry that last message is for john
Many Thanks John
This one Worked Perfect
https://gist.github.com/dodyrw/4943269
But is There any way to make it work Arabic too?
Regards
Ameer
Hi Samuel Nduati,
I make it work now for 2 language English and Arabic
>>> http://goo.gl/jpTD79 <<<
Here Are The Steps:-
1.Go To ----> public_html/libs/smarty/plugins
And Create file called >>modifier.timeAgo.php<< "note: you can create another one for other language as i did >>modifier.timeAgo-ar.php <<
Then edit file and paste this code inside it :-
2.Now go to Use This to call the listing date in tpl file --> to Get Full Time use thisCode:Only registered members can view the code.
And if you want just Time Ago from posting ad use this only:-Code:Only registered members can view the code.
3.This one used in listing detail block for category listing block or listing.tpl just use this:Code:Only registered members can view the code.
Hope everyone be happyCode:Only registered members can view the code.
My Regards
Ameer
Last edited by Ameer Hassan; May 31, 2016 at 12:25 PM.
Hello Nail,
You can try to use this code:
in file: ftp://templates>>your_template>>tpl>>blocks>>listing.tplCode:Only registered members can view the code.
Viktor,
Flynax technical department,
Best wishes.
That code did not work sorry Viktor..
Change to
<span> {$listing_data.Date|date_format:$smarty.const.RL_D ATE_FORMAT}</span>
This One Works