Search the Community
Showing results for tags 'integer'.
I was hoping to be able to do this entirely in PHP but was having all kind of issues getting it to see my values as numbers instead of strings (got error messages because my PW debugging is currently set to true). I currently have about 10 cards that PW is generating that include thumbnails, descriptions, donation amounts (raised amounts and goal amounts), and donate buttons. What I was trying to do was take the goal amount divide it by the raised amount (using PHP) and simply insert that value into the Progress element's Value attribute. Sounded simple enough but I couldn't get PHP to simply divide those two fields. First I tried dividing the goal value by the raised value and inserting it into the value attribute, like so: <? php $raised = $page->get("raisedAmount$count"); $goal = $page->get("goalAmount$count"); $percent = $goalNum / $raisedNum; ?> <progress value="<?php echo $percent; ?>" max="100"></progress> Which gave me this error message: Uncaught TypeError: Unsupported operand types: string / string Then I tried converting the two strings to integers because apparently PHP couldn't detect they were numbers and do it, like so: <?php $raised = $page->get("raisedAmount$count"); $goal = $page->get("goalAmount$count"); $goalNum = (int) $goal; $raisedNum = (int) $raised; if ($raisedNum != 0) : $percent = $goalNum / $raisedNum; else: $percent = 0; endif; ?> <progress value="<?php echo $percent; ?>" max="100"></progress> but all of the progress bars remain at zero percent (not shown), even when I have values in some of the $raised variables. Please note, if I add this code: <?php echo $percent; ?> below the Progress element, it shows 0 on every single card, so the $percent is never calculated (as per the $percent = $goalNum / $raisedNum;) even though $raisedNum should not equal 0 during that iteration of the loop (the original code includes a loop, which I omitted to keep the code sections above smaller, notice the $count at the end of the $raised and $goal variable declarations). When the loop goes over "raisedAmount1" there is a value in there; however, after typecasting it to an integer ($raisedNum) the value is 0 for someodd reason instead of 40,000, which is what is in the $raisedAmount1 field in Processwire... I'm new to relatively new to PHP and Processwire and could really use some help on this one. Thanks in advance for any helpful replies!
Fieldtype Integer, dont save option max, min with value 0 (zero). Positive values (> 0) and negative (<0), perfectly preserved. Without 0, built-in filter is not working properly.
Hi guys, is there a way to declare numbers other than integer and float? My issue is that intgere is not enough for me because i'm dealing with multiple of bilions (let's say something like 111,532,372,567) Thanks, Rob
Hi, I'm trying to get partial match for fields of type integer, much like how %= and *= selectors works for string. Unfortunately these selectors are not working with numeric fields. Is it possible to do this? For example, if I have pages with control numbers 14975, 91432, 33333, 32414, 13256 I'm looking for something like: $pages->find("controlnumber%=14"); that would match 14975, 91432, and 32414, that would work for numeric fields. Thanks.