The quantity field does not allow fration numbers like 1/2, 1/4 Would be nice to have that. Otherwise the new Modul is great!

Comments

spazio’s picture

Version: » master

Just adding Version..

marble’s picture

You can use decimal fractions (0.5, 0.25 etc), which are easier to parse and do the multiplication on when using a modified yield.

spazio’s picture

Ok, thank you for the hint. I do it this way then. It is a bit strange to write e.g. 0.25 unit lemon, but I guess people will understand.

Thanks

Mario

drawk’s picture

Assigned: Unassigned » drawk

I will be working on allowing fractions (1/4, 1/2, 1/8, etc..) to be used in the input and on a setting to choose how they are displayed in the recipe admin area.

Patch forthcoming.

drawk’s picture

StatusFileSize
new1.58 KB

Patch attached.

This allows users to use fractions like "1/2" or "1/8" when entering ingredients. They are converted to decimal when being stored in the database.

I'll open a new issue for allowing an admin setting to determine how fractions are displayed when viewing a recipe.

marble’s picture

Looks good, but waiting until it can handle stuff like "1 1/2" before applying.

drawk’s picture

StatusFileSize
new1.87 KB

Should be fixed now.

marble’s picture

Status: Active » Fixed

Applied, thanks.

marble’s picture

Status: Fixed » Closed (fixed)
moonray’s picture

Nice patch. One little problem when trying to display 1/3 (and I guess any 3, 6, 9, etc. fraction), though.

I get the following fraction: 1026405035⁄1215752192T

moonray’s picture

Status: Closed (fixed) » Active
moonray’s picture

Status: Active » Reviewed & tested by the community
StatusFileSize
new1.38 KB

Attached a patch against CVS that will fix the conversion issues with thirds, sixths, ninths, and twelfths.

It's not as elegant as a mathematical formula, but effective for the most likely to be encountered fractions.

moonray’s picture

Assigned: drawk » moonray
StatusFileSize
new1.51 KB

Small change to make sure you don't get numbers like 23 1/1 instead of 24.
New patch uploaded.

marble’s picture

Thanks moonray. My dev drupal database is currently a bit messed up from some other stuff I was doing, but I shall get that cleared up and test/apply your patch within the next few days. From looking at it though, doesn't the substr rely on there being less than 10 whole units?

moonray’s picture

I'm not quite sure what you mean with your comment about substr? If you explain, and it's an issue, I'll try and fix it. :-)

marble’s picture

Well, I didn't test it out yet, but doing a substr($whatever, 2, 4) doesn't seem like it would get the right part of the string, if $whatever was "10.3333". (Admittedly fairly unlikely for a recipe, but possible if someone changes the yield to something large.)

moonray’s picture

Ah! Now I understand.

$conversionstr = substr((string) ($conversion - floor($conversion)), 2, 4);

The $conversion - floor($conversion) part removes all digits before the decimal point, so you know that you always have 0.xxxxxxxx, which is why I can safely do a substr. No issue here. :-)

marble’s picture

Assigned: moonray » marble
Status: Reviewed & tested by the community » Fixed

Ah great. Sorry it took me so long, but I have now finally tried it, and checked it in.

Anonymous’s picture

Status: Fixed » Closed (fixed)