Jump to content

diogo

Moderators
  • Posts

    4,296
  • Joined

  • Last visited

  • Days Won

    79

Everything posted by diogo

  1. Still, if the echo "Total grants:..." is inside the deepest foreach, there will always be dozens of "Total grants:..." in each <li> Edit: For the total in the end creating another variable should do the job: // before the first foreach: $finaltotal = 0; $dollars = $pages->find("grants.amount_approved!=''"); $total = 0; foreach ($dollars as $dollar) { foreach ($dollar->grants as $z) { $total += $z->amount_approved; } } echo "Total grants: <span>\${$total}</span>"; echo "</li>"; $finaltotal += $total; // in the end echo $finaltotal; I didn't read all the thread carefully, so if this doesn't make any sense, please ignore me
  2. And you want the sum of all those that appear? If so try this: $dollars = $pages->find("grants.amount_approved!=''"); $total = 0; foreach ($dollars as $dollar) { foreach ($dollar->grants as $z) { $total += $z->amount_approved; } } echo "Total grants: <span>\${$total}</span>"; echo "</li>"; Edit: damn code editor... had to fix some fix the quirks Edit2: Just one question. Why don't you use a table for this? People used them for years in situations where they shouldn't be used, but would be nice to see them in situations where they are supposed to be used
  3. That problem happens only with links that are stored in the database. An example would be a link in a tinyMce text area, and those are the ones that the module solves.
  4. I was reading this thread, and it felt like if you were all talking with Nanni Moretti's voice. Just wanted to share...
  5. And now, for something completely different http://line25.com/inspiration/line25-sites-of-the-week-for-june-28th-2013
  6. +1 for nice site +1 for jumpy menu
  7. diogo

    (no topic title)

    Maybe you can recover your avatar from the MODX forums
  8. Try $child->logo instead of $pages->logo
  9. Sorry, I wasn't really thinking when I did that... I guess my head is still on vacation mode (does this answer to your question kongondo? ) Should be working now.
  10. Makes all the sense to me. Added it to Github with a reference to both for the contribution. Thanks!
  11. And to revert (removes the id from the end of the string): foreach ($templates as $t) { $t->pageLabelField = preg_replace('/ id$/', '', $t->pageLabelField); $t->save(); }
  12. You can also add the ID to the "list of fields to display in the admin page list" field on the advanced tab on each template. To do it quickly for all templates, put this code on any page and load it: // get all templates foreach ($templates as $t) { // if fields are the default (empty shows only the title) if ($t->pageLabelField == "") { // make new string with title and id $t->pageLabelField = "title id"; } else { // if not, add " id" to the existing string $t->pageLabelField .= " id"; } // save the template $t->save(); }
  13. of course... thanks Soma
  14. Actually it makes sense that it doesn't work because it's a private property. Sorry for that... There's a "default link to css stylesheet" in the module's configuration options, did you try that? The weather is very unpleasant here for the moment, you should dream of other places
  15. I never tried this, but by looking at the module it appears that this would work: // if using Ryan's example: $rss = $modules->get("MarkupRSS"); $rss->title = "Latest updates"; $rss->description = "The most recent pages updated on my site"; $rss->css = "{$config->urls->templates}styles/rss.css"; // <- here goes the css url $items = $pages->find("limit=10, sort=-modified"); $rss->render($items); edit: oh, and welcome edit2: changed $config->path->templates to $config->urls->templates. Thxs for finding this Soma
  16. I think it isn't... and I'm not sure if uninstalling the module should delete the field. Or maybe it can ask if, and then delete. I guess Soma is right, and we are hijacking the thread with this...
  17. I was thinking of this when Pete created the install routines for my module http://processwire.com/talk/topic/3474-admin-custom-pages-module/?p=37140 Since we have field tags now, the modules that create fields could give them a tag with the name of the module and another tag that would be for all modules. The important here would be that all the modules use the same tag for the second case (let's say "modules"), and follow same logic for the first case (maybe the name of the module class...) I suspect that this would be the right way to create two field tags, one "modules" and one "module-admin-custom-pages". $field = new Field(); $field->type = $this->modules->get("FieldtypeTextarea"); $field->name = 'ACP_scripts_and_styles'; ... // create the field tags (the "-" before "modules" makes it collapsed in the admin) $field->tags = "-modules module-admin-custom-pages"; $field->save(); edit: my suspicion was right. It works. I will add this to the module as soon as we decide on a common tag for all modules. What do you guys think?
  18. Or we can work on a print.css for the cheatsheet. shouldn't be too difficult, and would always be on date.
  19. Little explanation of Wanze's code. Hope it helps: // total starts with zero $total = 0; // loop through all grants and store each of them in the $grant variable for their part of the loop foreach ($page->grants as $grant) { // echo this particular grant cheque_date echo "Date granted: {$grant->cheque_date}"; // echo this particular grant amount approved echo "Amount ${$grant->amount_approved}"; // add this particular grant amount approved to the total that we have in this moment (in the end of the loop the total will be the sum of all amounts) $total += $grant->amount_approved; } What you don't have in your code is "+=" that adds the amount of this grant to the total. In your code the total is always the same as the previous amount and in the end it will be equal to the last amount. -- $page->grants->sort('-cheque_date')->first()->cheque_date; For what I understand this returns the value the most recent cheque date. you can echo it directly like this: echo $page->grants->sort('-cheque_date')->first()->cheque_date; or store it in a variable $last_cheque_date = $page->grants->sort('-cheque_date')->first()->cheque_date; ...and use it later echo "the most recent cheque date is {$last_cheque_date}."; or // just a random example... if ($last_cheque_date < 165436524) { // do something }
  20. Or: echo "<h2>Amount \${$grant->amount_approved}</h2>";
  21. My code is assuming some things and has to be adapted to your situation. How did you use it exactly?
  22. I've just merged a pull request by Pete that automatically replaces the admin.php file and creates the scripts&styles field during installation. That's two steps less The version on github is now 1.0.4. Thanks Pete!!
  23. ... and if it still doesn't work, call as children of their parent (i'm assuming they have the same parent) $trabajos = $pages->get('trabajos-parent')->children("template=trabajo, sort=sort");
  24. Yep, never underestimate this sponge's absorbing power
×
×
  • Create New...