Skip to main content
Topic: comma_format() and relativeTime() in Templates? (Read 7564 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

comma_format() and relativeTime() in Templates?

 TE 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)
Thorsten "TE" Eurich
------------------------

Re: comma_format() and relativeTime() in Templates?

Reply #1

Quote from: TE –
 TE 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?
The best moment for testing your PR is right after you merge it. Can't miss with that one.

Re: comma_format() and relativeTime() in Templates?

Reply #2

I see, makes sense :) The controller would just send the plain timestamp and the template would render it to whatever ..
Thorsten "TE" Eurich
------------------------

Re: comma_format() and relativeTime() in Templates?

Reply #3

 emanuele writes a template where all the times and dates are rendered as timestamps! :D
Bugs creator.
Features destroyer.
Template killer.

Re: comma_format() and relativeTime() in Templates?

Reply #4

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
Thorsten "TE" Eurich
------------------------

Re: comma_format() and relativeTime() in Templates?

Reply #5

LOL
Bugs creator.
Features destroyer.
Template killer.

Re: comma_format() and relativeTime() in Templates?

Reply #6

I think they should be moved to Template.subs or similar to show that they are template helpers.