-
Posts
155 -
Joined
-
Last visited
-
Days Won
5
Everything posted by alxndre
-
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.
-
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!
-
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]");
-
Getting categories that have entries with Page Reference field
alxndre replied to mciccone's topic in General Support
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. -
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');
-
I think get() always returns a single page. Have you tried $pages->find("id=1|2|3"); which will return a PageArray.
-
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.
-
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!
-
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.
-
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!
-
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.
-
@Robin S thanks for confirming. I already submitted a bug report.
-
Searching using subfields values is working fine, for some reason, I can't make sorting with parent.pagefield work.
-
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.
-
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.
-
As an avid last.fm user, thanks. Could it probably get more info?
-
Programatically adding a page to FieldtypePage field
alxndre replied to lenno's topic in General Support
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(); -
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:
-
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.
-
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
-
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.
-
I'm interested to learn how this all works. Please nudge me to the right direction, with links perhaps, or examples specific to PW :).
-
Welcome to the ProcessWire community, and good luck.