Search the Community
Showing results for tags 'defect'.
-
I came across this earlier <https://processwire.com/talk/topic/5673-how-to-assign-users-to-page-field/?p=65747> and thanks to Soma I worked around it. I just came across it in a different context and forgot and spun my wheels. Unless I'm really misunderstanding, there's a defect in the lack of symmetry between using TypefieldPage in selectors in the $pages->find() vs. PageArray->find() and there should not be. Plainly, the following code should not behave like it does. The find() against the PageArray should return the same result but doesn't in the 1st example using name instead of ID. // a problem with TypefieldPage in selectors $selector = 'tags=plain'; echo "using \$selector : {$selector}\n"; $res = wire('pages')->find( $selector ); echo "using \$pages->find : {$res->count()}\n"; $res1 = $res->find( $selector ); echo "using pageArray->find : {$res1->count()}\n"; // versus $tag = wire('pages')->findOne( 'template=tag,name=plain' ); $selector = "tags={$tag->id}"; echo "using \$selector : {$selector}\n"; $res = wire('pages')->find( $selector ); echo "using \$pages->find : {$res->count()}\n"; $res1 = $res->find( $selector ); echo "using pageArray->find : {$res1->count()}\n"; /* output: using $selector : tags=plain using $pages->find : 1 using pageArray->find : 0 using $selector : tags=1343 using $pages->find : 1 using pageArray->find : 1 */ It's because the find/matches/(filter) methods work differently in Pages than in PageArray. I don't think this should be so. FYI, in this case, I'm building a form where tags can be assigned as a filter. It works well using tag->name if the filtering is against $pages, but not if it's against the results of $pages->find(), which I need because I need 2 layers of filtering. On to using tag->id... Did I mention I freeeekin' loooove pw? I do I do!
- 3 replies
-
- selectors
- fieldtypepage
-
(and 1 more)
Tagged with: