Jump to content

Galaxy

Members
  • Posts

    55
  • Joined

  • Last visited

Everything posted by Galaxy

  1. Thanks again. I feel like I owe ya something....
  2. 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>"; }
  3. No! See the above dude. You guys are funny. Love your work but I still have to tweak this...
  4. 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
  5. Hallelujah diogo! And, thanks Kongondo for perservering with this. This indeed works:
  6. 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!
  7. have you refreshed http://legacytrust.acumulus.co.nz/recipient-list/ It's showing all the individual items totals...
  8. 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.
  9. 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>";
  10. 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
  11. Right. I couldn't have said it better myself
  12. 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/
  13. 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.
  14. 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
  15. Getting closer this doesn't through up an error $dollars = $pages->find("grants.amount_approved!=''"); - but does make ALL items have Total grants: $798684 ...and, I can't seem to change that field to integer - only options are Datetime, Email, Text, Textarea, URL
  16. Sorry kongondo this isn't working. Here's my complete code for the template - I know I've frobably fckd up some nesting grants= repeater amount_approved = field (it's text not an integer though - and it's working on the actual page so I'm presuming it doesn't have to be an integer format) if($page->numChildren) { $result = $page->children("limit=200"); // render the pager echo $result->renderPager(); echo "<div style='padding-bottom:10px;'>"; echo "<span style='width: 300px; float:left; padding-left:60px;'>Recipient</span>"; echo "<span style='width: 160px; float:left;'>Logo</span>"; echo "<span style='width: 160px; float:left;'>Grants total</span>"; echo "</div>"; // render the children echo "<div class='scrollholder'>"; echo "<div class='scrollpanel no4'>"; 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 "<a href='{$child->logo->url}'><img src='/site/assets/uploads/yes.png'></a>"; } else{ echo "<img src='/site/assets/uploads/no.png'>"; } $total = 0; //grants = name of repeater; amount_approved = name of field in the repeater "grants" $dollars = $pages->find("grants.amount_approved>0");//grab pages whose repeater field "amount_approved" 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>"; echo "</li>"; } echo "</ul>"; echo "</div>"; echo "</div>"; // render pager again? ok echo $result->renderPager(); } Error: Exception: Unimplemented operator in DatabaseQuerySelectFulltext::match() (in /var/www/vhosts/acumulus.co.nz/subdomains/legacytrust/httpdocs/wire/core/DatabaseQuerySelectFulltext.php line 100) #0 /var/www/vhosts/acumulus.co.nz/subdomains/legacytrust/httpdocs/wire/modules/Fieldtype/FieldtypeText.module(117): DatabaseQuerySelectFulltext->match('field_amount_ap...', 'data', '>', '0') #1 /var/www/vhosts/acumulus.co.nz/subdomains/legacytrust/httpdocs/wire/core/PageFinder.php(286): FieldtypeText->getMatchQuery(Object(DatabaseQuerySelect), 'field_amount_ap...', 'data', '>', '0') #2 /var/www/vhosts/acumulus.co.nz/subdomains/legacytrust/httpdocs/wire/core/Wire.php(271): PageFinder->___getQuery(Object(Selectors)) #3 /var/www/vhosts/acumulus.co.nz/subdomains/legacytrust/httpdocs/wire/core/Wire.php(229): Wire->runHooks(Array, Array) #4 [internal function]: Wire->__call('getQuery', Array) #5 /var/www/vhosts/acumulus.co.nz/subdomains/legacytrust/httpdocs/wire/core/PageFinder.php(145): PageFinder->getQuery('getQuery', Arra This error message was shown because you are logged in as a Superuser. Error has been logged.
  17. $total = 0; foreach ($pages->find('grants.amount_approved>0') as $grant) { $total += $grant->amount_approved; } echo "<span class='total'>\${$total}</span>"; I am having trouble with this. Please can anyone see why this might not be working?
  18. Thanks again for your help on this but the following error has happened 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 "<a href='{$child->logo->url}'><img src='/site/assets/uploads/yes.png'></a>"; } else{ echo "<img src='/site/assets/uploads/no.png'>"; } $total = 0; foreach ($pages->find('grants.amount_approved') as $grant) { $total += $grant->amount_approved; } echo "<span class='total'>\${$total}</span>"; echo "</li>"; } echo "</ul>"; Error: Exception: Unknown Selector operator: '' -- was your selector value properly escaped? (in /var/www/vhosts/acumulus.co.nz/subdomains/legacytrust/httpdocs/wire/core/Selectors.php line 165) #0 /var/www/vhosts/acumulus.co.nz/subdomains/legacytrust/httpdocs/wire/core/Selectors.php(190): Selectors->create('grants.amount_a...', '', '') #1 /var/www/vhosts/acumulus.co.nz/subdomains/legacytrust/httpdocs/wire/core/Selectors.php(63): Selectors->extractString('has_parent=1001...') #2 /var/www/vhosts/acumulus.co.nz/subdomains/legacytrust/httpdocs/wire/core/Pages.php(143): Selectors->__construct('has_parent=1001...') #3 /var/www/vhosts/acumulus.co.nz/subdomains/legacytrust/httpdocs/wire/core/Wire.php(271): Pages->___find('has_parent=1001...', Array) #4 /var/www/vhosts/acumulus.co.nz/subdomains/legacytrust/httpdocs/wire/core/Wire.php(229): Wire->runHooks(Array, Array) #5 [internal function]: Wire->__call('find', Array) #6 /var/www/vhosts/acumulus.co.nz/subdomains/legacytrust/httpdocs/wire/core/Page.php(786): Pages->find('fi This error message was shown because you are logged in as a Superuser. Error has been logged.
  19. Thanks kongondo. I've done this below and all totals are $0 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 "<a href='{$child->logo->url}'><img src='/site/assets/uploads/yes.png'></a>"; } else{ echo "<img src='/site/assets/uploads/no.png'>"; } $total = 0; foreach ($pages->find("template=recipients, limit=10") as $grant) { $total += $grant->amount_approved; } echo " Total grants: <span>\${$total}</span>"; echo "</li>"; } echo "</ul>";
  20. I've posted a topic http://processwire.com/talk/topic/3938-output-of-child-fields/ but one of the Snr members has suggested I change the title as no one has answered the question. So how do I change the topic title?
  21. I have a site that is a directory of Recipients that receive Grants. I have set up a template that lists all children (Recipients) of a parent page and need to output the total Grants of combined fields (each child page has a repeatable field called "amount_approved") The following works on an individual child page to display a running amount of grants received and their total, plus the date of the most recent date a payment was made <?php $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> "; $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>"; ?> That works fine... but what I am having trouble with is adding the total amounts approved into the parent of this page (the parent page is a listing of all child pages with a summary of a few things - the total of all amounts approved being one of them, and also whether the organisation has supplied their logo. The following successfully loads a graphic "yes.png" if a logo has been uploaded, and "no.png" if it hasn't 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 "<a href='{$child->logo->url}'><img src='/site/assets/uploads/yes.png'></a>"; } else{ echo "<img src='/site/assets/uploads/no.png'>"; } echo "</li>"; } My question is, how do I also add the total of all amount_approved fields into the parent as I successfully did in the actual child page? I want it to display the total as a $ amount after the image has loaded.
×
×
  • Create New...