Jump to content

devsmo

Members
  • Posts

    9
  • Joined

  • Last visited

Everything posted by devsmo

  1. Thanks! In our case the dataset is fairly small, so I can do the sorting in code. I imagine this could be a pretty annoying problem in some more complex projects. Hope Ryan gets around to this one at some point ?
  2. Hello, Sorting a set of pages based on subfields seems to work quite well. Both of these have worked just fine for us: sort=parent.name sort=customers.title However sorting based on a parent pages subfield doesn't seem to work sort=parent.customer.title Is there some trick for this., or should I just write my own array sorter before printing my content? My actual selector looks something like this: <?php // get stuff $items = array(); $items[] = 'template=entry'; $items[] = 'product.category=ilmoitukset|liitteet'; $items[] = 'sort=product'; $items[] = 'sort=parent.customer.title'; // <-- this does not work /* ... */ $items = $pages->find(implode(", ", $items)); We use Processwire version 3.0.62 at the moment.
  3. Hello, I'm building a web app using PW as the backend. Within the app there's a advanced search tool which allows searching using ID's. This search needs to be able to search stuff with template=x AND (ID=y OR parent.ID=y). It would seem Processwire doesn't handle this? template=entrytpl, parent.id|id=7077, sort=relatedstuff.release_date, sort=someotehrfield, start=0, limit=100 It doesn't cause an error, but the search only happens on one of the IDs (it would seem parent id). Is there some workaround or solution for this? This site runs on PW 2.7.3, upgrading is not an option for a while yet.
  4. I spent some time dumping and analyzing the SQL queries that PW does when doing the find. It seems that find() works fine. Instead the issue appears when we save pages via the API. The page that cannot be found with find is missing entries in the pages_parents table, The first query is a broken page, and the second one is a sibling which works as expected. mysql> SELECT * FROM pages_parents WHERE pages_id=1754; Empty set (0.00 sec) mysql> SELECT * FROM pages_parents WHERE pages_id=1407; +----------+------------+ | pages_id | parents_id | +----------+------------+ | 1407 | 1 | | 1407 | 1172 | | 1407 | 1193 | +----------+------------+ 3 rows in set (0.00 sec) I'll post a conclusion here if I ever manage to duplicate this issue consistently.
  5. It actually returns an empty PageArray. And the error (notice), is probably about the '->id' EDIT, Here's a bit of the var_dump for $page->find('template=email-base'): --- object(PageArray)[297] protected 'numTotal' => int 0 protected 'numLimit' => int 0 protected 'numStart' => int 0 protected 'selectors' => object(Selectors)[292] protected 'selectorStr' => string 'has_parent=1754, template=email-base' (length=48) protected 'quotes' => array (size=5) '"' => string '"' (length=1) ''' => string ''' (length=1) '[' => string ']' (length=1) '{' => string '}' (length=1) '(' => string ')' (length=1) .. ---
  6. - This project isn't multi-language. - The pages are created through the api. When I moved all the grandchildren down one level, so that $page only has children and no grandchildren: $pages->find("has_parent=$entry->id") returned empty. I also tested this in a template, while being logged in as admin var_dump( $page->children('template=email-base')->first()->id ); var_dump( $page->get('template=email-base')->id ); var_dump( $page->child()->id ); var_dump( $page->find('template=email-base')->first()->id ); The 3 first ones return the page id. The last one throws an error (since first() isn't a method of null).
  7. The version is 2.5.3 I tested with $pages->find("has_parent=$entry->id"); and $pages->find("parent_id=$entry->id"); The later returned the template page as expected, and the first query returned the 5 grandchildren
  8. I checked that as well. At least according to the admin panel the page is published, visible and accessible by guest.
  9. Hello, Recently I ran into some weird behavior with the find() method, when using it within the context of a single $page. Although this is easy (and perhaps more correct) to work around using the get(), child() or children() methods, I'd still like to understand what is happening here. This is an example of a piece of code, where $page is trying to get its child with a specific template, using the find() method, but returns nothing instead. <?php // Prepare PW $_SERVER['SERVER_NAME'] = 'localhost'; $_SERVER['HTTP_HOST'] = 'localhost'; $_SERVER['REQUEST_URI'] = '/index.php'; // get Wire'd require_once dirname(__FILE__).'/../../www_composer/index.php'; // get some entries where the template failed to laod $data = file_get_contents('failed_entries.json'); $data = json_decode($data); foreach ( $data as $row ) { $entry = wire('pages')->get('template=offers-page, email='. $row->email); echo sprintf("This page has the id %d, it contains meta-data for an email\n", $entry->id); echo sprintf("\t- it has %d child (with ID %d), which is a template ('email-base'),\n", $entry->numChildren(), $entry->child()->id ); echo sprintf("\t- the child (template) has %d children (which are blocks in the template),\n", $entry->child()->numChildren()); echo "We want to get the child that uses the 'email-base' template (because in theory there could be many children to this page)\n"; echo sprintf( "\tWhy is find() returning '%s' when filtering with template name,\n", ($entry->find('template=email-base')->count()? $entry->find('template=email-base')->count(): 'NOTHING') ); echo sprintf( "\twhile get() returns the expected page with id: %d\n", $entry->get('template=email-base')->id ); echo "When further researching this, it would seem that using find on \$page, actually returns it\'s grandchildren\n"; $i=1; foreach ( $entry->find() as $gc ) { echo sprintf("\t- I'm a grandchild, and my parent is %d and not %d\n", $gc->parent()->id, $entry->id ); $i++; } break;// casue we only need to look at one.. } Even more interesting is that sometimes this $page->find('template=tpl-name')->first()->id returned an id, and sometimes it threw a notice. The above code is a test CLI script, which produces weird results. On the other hand when I tested using find() in a template, it worked while testing, but later our users reported an error that is caused by $page->find('template=tpl-name')->first()->id throwing a notice. What is the behavior of find() supposed to be in this case? Am I missing something?
×
×
  • Create New...