Jump to content

kongondo

PW-Moderators
  • Posts

    7,479
  • Joined

  • Last visited

  • Days Won

    146

Everything posted by kongondo

  1. If it works for you, well, and if there are no severe strains on your server and if you've thought this through, then, yes....But, as has been said before, repeaters were designed for something else and not to categorise content...Most people here will categorise content using methods stated above...it is good practice.. I'm sure you've seen this:
  2. Change the following code... $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>"; to //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; $total = 0; foreach ($u as $z) { $total += $z->amount_approved; } echo "Total grants: <span>\${$total}</span>"; }
  3. OK, Is the following the situation? So, your tree goes something like... recipient acorn foundation althorp trust aglow int abilities in action 1st O. scouts Each of those child recipient pages (aglow, etc.). have several repeater fields. And, adding the totals on each child page (e.g. aglow) adds up fine with the code on your first post And, now you want to pull those child totals and list them as shown in the link to recipient list? E.g. aglow $1000 acorn foundation $4000 althorp trust $7000 Right?
  4. kongondo

    HELP

    DB Host = localhost. Maybe? Edit: forgot the host part...thanks horst!
  5. OK...I am now getting you partially...My code does the grand total across the whole site... I am not getting what you mean by list page.please explain..What is on that list? A list of ALL grants across the site? A list of ALL grants in a category (e.g. international grants)....an illustration would help I have a feeling it is about choosing the right selector (e.g. templates="xyz" or parent="123"). Try adding the parent of the listed pages (assuming I get you correctly) to the selector..., i.e. parent=ID of parent or path/to/parent Edit: if there are various parent pages that will have various listings of grants of their child pages, then try to add this to your selector.. $dollars = $pages->find("grants.amount_approved!='', parent=$page ");
  6. You've checked your fields are not empty? What type of text field is that? What do you mean it created one output? How many outputs do you want? I thought you wanted one grand total on the parent page? Is $798684 the correct amount for the grand total?
  7. Strange...and without the ' '? i.e. != instead of !=' '....just guessing here... Edit: What about as standalone? Does the totals code work?
  8. To use it with > or < it has to be an integer I believe. I think it works better with integers if you are comparing numbers . If you still want to use a text area, you can check if the text area is empty or you can do something like below. I am not sure if it will work correctly though... $dollars = $pages->find("grants.amount_approved !=0"); //OR $dollars = $pages->find("grants.amount_approved!=''"); Briefly tested...
  9. Nice! +1 one for separation of core and site...
  10. I think this is answered here http://processwire.com/talk/topic/3938-adding-total-field-amounts-based-on-child-fields/
  11. Hi gtoirog, Welcome to PW and the forums! totoff is right; you don't want to use repeater fields to categorise content. I don't know how much reading you've done (about PW). This thread would be useful for categorising content. May I also suggest, it is (at least for me) easier to understand what you are trying to achieve if it can be visualised. So, something like how you tree structure looks like and the relationships you are trying to take advantage of helps. Eg. My tree looks like this: Home plants Species Color Etc
  12. Hi Galaxy, The following should work (tweak the example). You need to get arrays within arrays...hence, nested foreach.... $total = 0; //grant = name of repeater; grants = name of an integer field in the repeater "grant" $monies = $pages->find("grant.grants>0");//grab pages whose repeater field "grants" value are more than 0 foreach ($monies as $peso) { $u = $peso->grant; foreach ($u as $z) { $total += $z->grants; } } echo "<h3>Total grants: <span>\${$total}</span></h3><hr> ";
  13. I didn't know this. Thx Teppo...I need to click on the "wrench" in the modules list more often!
  14. You need to implement that similar to the examples found here...about repeaters.. For example: foreach ($pages->find("grants.amount_approved>0") as $grant) { //do stuff } //where, grants = the name of your repeater field; and amount_approved is the name of the field within the repeater field containing the amounts $ Hope this helps...it is just an example
  15. Have you tested with something similar to... $total = 0; foreach ($pages->find("template=recipients, limit=10") as $grant) { $total += $grant->amount_approved; } echo "<h3>Total grants: <span>\${$total}</span></h3> "; //or, find using parent="/path/to/parent/" or parent=123 This works for me using normal integer fields in child pages. From what I recall, repeaters are accessed the same way as fields in other pages...
  16. click edit, then click use full editor, then edit topic title
  17. click edit, then click use full editor, then change the title...
  18. Maybe change the topic title to be more descriptive? E.g. "Adding total amounts based on child fields" or something similar
  19. kongondo

    (no topic title)

    I like it! I'll take it! Just what the doctor ordered, thanks, hehe!
  20. I prefer the faded style suggested by Ryan rather than a strike-through...
  21. Hi anowitz, It's probably not a good idea to publicly post your phpinfo file like that
  22. Bellissima!! the main menu is a bit jumpy for me though
×
×
  • Create New...