Sultanen
Sultanen

Reputation: 3412

CakePHP - How to perform unit conversions?

How to perform a unit convertion in a nice way with CakePHP? I have all mesurment values saved in "mm" in the database, if the user has another perfered mesurmentsystem then "metric" i need to convert and display the mesurments in that system.

Upvotes: 0

Views: 114

Answers (1)

mark
mark

Reputation: 21743

Make a lib class in /Lib where you put the basic conversion stuff. Then you either use it as Lib directly anywhere in your app (model etc) or you can extend it as a helper for your view level.

Check out how the core does it with CakeNumber and NumberHelper, CakeTime and TimeHelper and String and TextHelper. Analogously should you code your measurement conversion.

Upvotes: 1

Related Questions