Galaxy
Members-
Posts
55 -
Joined
-
Last visited
About Galaxy
- Birthday 12/14/1965
Profile Information
-
Gender
Male
-
Location
Aotearoa, NZ
-
Interests
Old Punk Rock and New Suede Shoes
Galaxy's Achievements
Full Member (4/6)
6
Reputation
-
Adding total field amounts based on child fields
Galaxy replied to Galaxy's topic in Getting Started
Thanks diogo -
Adding total field amounts based on child fields
Galaxy replied to Galaxy's topic in Getting Started
Thanks again. I feel like I owe ya something.... -
Adding total field amounts based on child fields
Galaxy replied to Galaxy's topic in Getting Started
added, and all good. Thanks guys. Love your work. foreach($result as $child) { echo "<li>"; echo "<a href='{$child->url}' class='list-title'>{$child->title}</a>"; $image = $child->logo; if (count($child->logo)){ echo "<span style='padding-right:140px;'><a href='{$child->logo->url}'><img src='/site/assets/uploads/yes.png'></a></span>"; } else{ echo "<span style='padding-right:140px;'><img src='/site/assets/uploads/no.png'></span>"; } // and from here on do the same as you did in the individual page, but adapted ($page is now $child) $total = 0; foreach ($child->grants as $grant) { $total += $grant->amount_approved; } echo "Total grants: <span>\${$total}</span>"; echo "</li>"; } -
Adding total field amounts based on child fields
Galaxy replied to Galaxy's topic in Getting Started
No! See the above dude. You guys are funny. Love your work but I still have to tweak this... -
Adding total field amounts based on child fields
Galaxy replied to Galaxy's topic in Getting Started
Hold on a minute!! I think it's now adding up each and creating a running total... http://legacytrust.acumulus.co.nz/recipient-list/ see how the numbers combine and increase down the list -
Adding total field amounts based on child fields
Galaxy replied to Galaxy's topic in Getting Started
Hallelujah diogo! And, thanks Kongondo for perservering with this. This indeed works: -
Adding total field amounts based on child fields
Galaxy replied to Galaxy's topic in Getting Started
Kongondo if I do like you suggest No totals appear so I've got echo "<ul class='nav'>"; echo "<li>"; foreach($result as $child) { echo "<a href='{$child->url}' class='list-title'>{$child->title}</a>"; $image = $child->logo; if (count($child->logo)){ echo "<span style='padding-right:140px;'><a href='{$child->logo->url}'><img src='/site/assets/uploads/yes.png'></a></span>"; } else{ echo "<span style='padding-right:140px;'><img src='/site/assets/uploads/no.png'></span>"; } $dollars = $pages->find("grants.amount_approved!=''"); foreach ($dollars as $dollar) { $u = $dollar->grants; $total = 0; foreach ($u as $z) { $total += $z->amount_approved; } echo "Total grants: <span>\${$total}</span>"; } } echo "</li>"; echo "</ul>"; note: moved the <li> to outside all foreach I feel like it's getting close... might be the 4th coffee this morning... kongondo Yes! -
Adding total field amounts based on child fields
Galaxy replied to Galaxy's topic in Getting Started
have you refreshed http://legacytrust.acumulus.co.nz/recipient-list/ It's showing all the individual items totals... -
Adding total field amounts based on child fields
Galaxy replied to Galaxy's topic in Getting Started
My head is spinning and I'm sure my explanations are being misinterpreted somehow and I apologise, but here goes... On an individual page (eg. http://legacytrust.acumulus.co.nz/recipient-list/1st-otumoetai-scouts/ ) You'll see how it has 2 grants (with their dates) and their total 1. 1 August 2012 $1000 2. 1 Junwe 2013 $500 Total grants: $1500 This is fine and is using the following echo "<ol>"; foreach ($page->grants as $grant) { echo "<li>{$grant->cheque_date} "; echo "<span>\${$grant->amount_approved}</span></li>"; $total += $grant->amount_approved; } echo "</ol>"; echo "<h3>Total grants: <span>\${$total}</span></h3> "; $last_cheque_date = $page->grants->sort('-cheque_date')->first()->cheque_date; echo "<p>The most recent cheque date is <span>{$last_cheque_date}</span>.</p>"; Now, go back to the Recipient list http://legacytrust.acumulus.co.nz/recipient-list/ All I want to do is have the total of each individual's grants within its own <li> after the link to its own page and the icon to show if a logo has been uploaded. -
Adding total field amounts based on child fields
Galaxy replied to Galaxy's topic in Getting Started
getting there but... http://legacytrust.acumulus.co.nz/recipient-list/ this is the complete list code echo "<ul class='nav'>"; foreach($result as $child) { echo "<li>"; echo "<a href='{$child->url}' class='list-title'>{$child->title}</a>"; $image = $child->logo; if (count($child->logo)){ echo "<span style='padding-right:140px;'><a href='{$child->logo->url}'><img src='/site/assets/uploads/yes.png'></a></span>"; } else{ echo "<span style='padding-right:140px;'><img src='/site/assets/uploads/no.png'></span>"; } $dollars = $pages->find("grants.amount_approved!=''"); foreach ($dollars as $dollar) { $u = $dollar->grants; $total = 0; foreach ($u as $z) { $total += $z->amount_approved; } echo "Total grants: <span>\${$total}</span>"; } echo "</li>"; } echo "</ul>"; -
Adding total field amounts based on child fields
Galaxy replied to Galaxy's topic in Getting Started
so I've got this $total = 0; //grants = name of repeater; amount_approved = name of a field in the repeater "grant" $dollars = $pages->find("grants.amount_approved!='', parent=$page"); foreach ($dollars as $dollar) { $total += $dollar->amount_approved; } echo "Total grants: <span>\${$total}</span>"; but all items output $0 -
Adding total field amounts based on child fields
Galaxy replied to Galaxy's topic in Getting Started
Right. I couldn't have said it better myself -
Adding total field amounts based on child fields
Galaxy replied to Galaxy's topic in Getting Started
A list of all Recipients - which are child pages of the Recipient (what I call) category. Sorry I though my first post explained the scenario http://legacytrust.acumulus.co.nz/recipient-list/ -
Adding total field amounts based on child fields
Galaxy replied to Galaxy's topic in Getting Started
no I want totals for each item on the list (each item is a page). On the individual page, the following successfully shows all grants and the total of all the grants. Which prooves the fileds are not empty. $total = 0; echo "<ol>"; foreach ($page->grants as $grant) { echo "<li>{$grant->cheque_date} "; echo "<span>\${$grant->amount_approved}</span></li>"; $total += $grant->amount_approved; } echo "</ol>"; echo "<h3>Total grants: <span>\${$total}</span></h3> "; when you are on the list page I want it to show a summary beside the link to each individual page. It looks like it ahs totalled ALL the amounts_approved from all child pages. So yeah, I can use this as the grand total, but it's not what I want beside each page listing. -
Adding total field amounts based on child fields
Galaxy replied to Galaxy's topic in Getting Started
yeah I took everything out except $total = 0; //grants = name of repeater; grants = name of an integer field in the repeater "grant" $dollars = $pages->find("grants.amount_approved!=''");//grab pages whose repeater field "grants" value are more than 0 foreach ($dollars as $dollar) { $u = $dollar->grants; foreach ($u as $z) { $total += $z->amount_approved; } } echo "Total grants: <span>\${$total}</span>"; and it created 1 output only with Total grants: $798684