ElkArte Community

Elk Development => Feature Discussion => Topic started by: TE on May 09, 2013, 01:23:04 am

Title: comma_format() and relativeTime() in Templates?
Post by: TE on May 09, 2013, 01:23:04 am
/me was just wondering about so many occurrences of comma_format() and relativeTime() inside the template files..
Honestly, it's somewhat a string manipulation (preparing $context)) and should be part of the controller, not the template, right?

https://github.com/elkarte/Elkarte/wiki/Architecture

If we strictly follow this route we would need to get rid of $context in subs files (hard work, I know) and move function calls from the template to the controller (such as comma_format() and relativeTime(), maybe more)
Title: Re: comma_format() and relativeTime() in Templates?
Post by: TestMonkey on May 09, 2013, 01:46:24 am
Quote from: TE – /me was just wondering about so many occurrences of comma_format() and relativeTime() inside the template files..
Honestly, it's somewhat a string manipulation (preparing $context)) and should be part of the controller, not the template, right?

No... I think it's more the other way around...
Controller sends data. Template receives it, and will display it in any way it wants. Further string manipulation of the raw data is more the job of the template, or template helper functions [which do no exist, but perhaps should?].
If I want to use standardTime in the custom template, shouldn't I receive time, and change the call to relativeTime() to standardTime() at my ease?
Title: Re: comma_format() and relativeTime() in Templates?
Post by: TE on May 09, 2013, 01:58:51 am
I see, makes sense :) The controller would just send the plain timestamp and the template would render it to whatever ..
Title: Re: comma_format() and relativeTime() in Templates?
Post by: emanuele on May 09, 2013, 03:41:49 am
/me writes a template where all the times and dates are rendered as timestamps! :D
Title: Re: comma_format() and relativeTime() in Templates?
Post by: TE on May 09, 2013, 03:46:37 am
01010100 01000101 00100000 01101001 01110011 00100000 01100011 01110101 01110010 01110010 01100101 01101110 01110100 01101100 01111001 00100000 01110100 01110010 01100001 01101110 01110011 01101100 01100001 01110100 01101001 01101110 01100111 00100000 01100001 01101100 01101100 00100000 00100100 01110100 01111000 01110100 00100000 01110110 01100001 01110010 01110011 00100000 01101001 01101110 01110100 01101111 00100000 01100010 01101001 01101110 01100001 01110010 01111001 00100000 00111011 00101001
Title: Re: comma_format() and relativeTime() in Templates?
Post by: emanuele on May 09, 2013, 03:58:39 am
LOL
Title: Re: comma_format() and relativeTime() in Templates?
Post by: Joshua Dickerson on May 09, 2013, 12:46:03 pm
I think they should be moved to Template.subs or similar to show that they are template helpers.