Jump to content


  • Posts

  • Joined

  • Last visited

  • Days Won


Everything posted by alxndre

  1. I just happened upon something that I think is curious, and I'm wondering if this is default behavior. So help me because I know nothing. While writing a module, i logged something in wire('log') inside the module's init() function. I was surprised to see that the text was being logged multiple times continuously. So I tried to open a small random module and logged something in its init() function as well, and the same thing happened - the text being logged many times. My question is, is this supposed to happen? I just want to understand what's going on. My concern is that if I do something huge in the init function, it will get called repeatedly, as with the log, and cause performance issue. Please note that these are both autoload modules. I was expecting them to log at least once when I refresh, but not continuously like what happened. Please let me know. Thanks.
  2. Thanks for the response, I tried without logging but it's the same. And also, sorry bout the wrong selector, you're right it should be parent=[selector] as a subselector. I'll try later using find only. Thanks!
  3. function copyParent($begin, $times) { for ($i=$begin; $i<=$times; $i++) { $limit = 50; $set = $i; $start = ($set-1) * $limit ; $tx = wire('pages')->findMany("template=transaction-earn, start=$start, limit=$limit, sort=transactiondate"); if ($tx->count < 1) { wire('log')->save('migration', "no mas transaciones"); break; } wire('log')->save('migration', "updating $start to" . $set*$limit); foreach($tx as $t) { $p = $t->parent; $t->setAndSave([ 'tagreference' => $p->tagreference, 'idreference' => $p->idreference, 'transactiondate' => $p->transactiondate, 'merchantreference' => $p->merchantreference, 'userreference' => $p->userreference, 'terminalreference' => $p->terminalreference, 'offline' => $p->offline, 'amount' => $p->amount, 'product' => $p->product ]); } } } I have this code that i'm trying to run in the background to copy some data from a parent node to a child node. The problem is each iteration of this code runs for about 15 seconds for every 50 pages saved / copied (or about 200/minute). I have about half a million of these pages to update and it would take 2 straight days running. Maybe someone could point me out to what's causing the slow down? Or if anyone could suggest a better way to do what i'm trying to do. Thank a lot, as usual. Edit: By the way, the reason I'm doing this is because when I'm trying to query the child nodes with criteria from the parent node, it takes an incredibly long time, but takes close to nothing when I tried copying some to the child node and do the query there. I hope that helps a bit. $tx = wire('pages')->findMany("template=transaction-earn, start=$start, limit=$limit, sort=transactiondate, [tagreference=$tag, merchantreference=$merchant]");
  4. Your selectors are not actually doing anything to filter the posts you want: If for example you have a category called "tech" and you want to find articles with that "category" field, you could do: $category = $pages->get("template=category, title=tech"); $posts = $pages->find("template=article-post, category=$category"); This also works with filtering multiple categories: $categories = $pages->find("template=category, title=tech|botany"); $posts = $pages->find("template=article-post, category=$categories"); Now, if you want to do your list with the headings and the posts underneath them, you'd have to loop through your categories and do the same thing. Hope it helps.
  5. If you're using the processwire variables within a function, you could reference them using the wire() function such as: wire('pages')->find('selector'); wire('users')->get('selector');
  6. I think get() always returns a single page. Have you tried $pages->find("id=1|2|3"); which will return a PageArray.
  7. Once they wrapped their heads around that analogy, we can proceed and explain the PageClone module using this : Kidding aside, I explain these templates to myself in terms of OOP where template = class, fields = members, and pages = objects. But biology is fine, too.
  8. I wanted to display the child pages inside the page containing them, for simplicity, and there's possibly hundreds of them. But I'm planning to buy the ProFields later this week, and it's good to know that FieldtypeTable supports pagination! Lister looks like a better solution too. I just haven't had time to play with these modules yet. Thanks!
  9. Is there a way to paginate to the contents of a pagetable? I'm currently creating a page with a pagetable field that could possibly have hundreds of pages underneath. Has anybody done this? Thanks.
  10. It's the small, convenient things like this makes me love the processwire community even more. I tend to create some placeholder pages while developing, so this will save me a lot of clicks. Thanks!
  11. I can confirm, and also setting label to {parent.something.title} when something is a page reference doesn't work too. I think this is might be related to another bug I encountered when sorting with page reference fields, i.e. "sort=field.subfield" when field is a page reference; it throws an exception.
  12. @Robin S thanks for confirming. I already submitted a bug report.
  13. Searching using subfields values is working fine, for some reason, I can't make sorting with parent.pagefield work.
  14. Hi, @Zeka, Sorry for the big edit, I was totally swimming in my head coding til morning. But thanks for pointing me to subselectors! I've been using ProcessWire since 2012, but never heard of it and it looks amazing. I should probably read the PW weekly more often.
  15. I'm trying to sort pages based on their parent's fields, which are page references. For instance: $someOrders = $pages->find("template=order, sort=parent.customer.id"); Here, order's parent has a template called 'orderslip' that has multiple 'order' children. Orderslip contains a page field called customer, and I want to sort based on the parent's customer's id. But i can't make it work. It throws out an exception: Error: Exception: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'customer' in 'order clause' (in /srv/rewwwards/wire/core/PageFinder.php line 410) I'm sure customer page field exists and it works everywhere else. It's just that this time, I'm trying to sort it from a page's 'parent' selector. Is it even possible do this? As always, any help is greatly appreciated. Thanks.
  16. As an avid last.fm user, thanks. Could it probably get more info?
  17. Try turning off output formatting before setting values of fields, and also don't forget to save. $page->of(false); // turn of output formatting $page->a_field_of_fieldtype_page->add($anotherPageOrID); $page->save(); Or if your pagefield is set to a single value: $page->of(false); // turn of output formatting $page->a_field_of_fieldtype_page = $anotherPageOrID; $page->save();
  18. Additionally, if you look at the link on the user template that says: To configure what fields a user can edit in their profile, see the profile module settings. You will be able to choose which fields are editable by users themselves. Like so: When users log in, their profile will be editable like:
  19. Hi @Robin S, I'd like to know if this modules works with API calls, or just within the admin page? Assuming I have a properly setup pages called cards and members that reference each other, and I write something like: $member = $pages->get(123); $card = $pages->get(456); $card->members->add($member); $card->save(); echo $member->card->title; Should I expect the code to output the card's title? I actually tried it out and it didn't work. But maybe I'm just doing something wrong. The fields work okay when setting them using the page editor. Thanks.
  20. Thanks Robin. I was able to make it work with some modifications by just returning the ids (instead of the whole page) for pagefields. Another concern I have is that the json response that I get has [] brackets at the end. Sample: { "id":1058, "firstname":"Julie Ann Mae", "sex":[1], "birthdate":768931200, "nationality":[93], "guardians":[1059,1060] }[] Is this normal behavior? I can't figure out where it gets inserted. It's been returning that from the beginning. EDIT: I got it. It was totally my fault. Thanks
  21. I'm trying out this module as well. I was able to add support for SelectableOption and SelectableOptionArray. Then I ran into an infinite loop. I'm using @Robin S's ConnectPages to connect some of my templates, and it would go on until it reaches max exec time. For example: Jane (Page) - Progenitors (Page Multiple) - John (Page) John (Page) - Progeny (Page Multiple) - Jane (Page) So when it's iterating over Jane's fields, it would come into it's progenitor field which is a multi page field, and would start listing John's fields. In there it would come into John's progeny field and would start listing Jane's data again, and would find John... and so on.. Would anyone have an idea on how to stop the loop from going over and over, or a way to stop the recursion from going too deep? I'd appreciate any help. Thanks.
  22. I'm interested to learn how this all works. Please nudge me to the right direction, with links perhaps, or examples specific to PW :).
  23. alxndre

    i <? php

    Been coding days and nights in php and processwire for a long while now. Took a little break and made this.
  24. Welcome to the ProcessWire community, and good luck.
  • Create New...