Jump to content
Spyros

Api $page->find - Missing records from the output - issue with pages with the same "PAGE NAME"

Recommended Posts

Hello

I'm having a strange issue with the $page->find(), for some reason I'm missing some of the pages from the results. I found then that I was missing all the pages with the same "PAGE NAME". Is it a bug or am I missing something?

PS 
If I change the "PAGE NAME" of one of the missing ones then I'm retrieving the page without any problem.

Thank you

Share this post


Link to post
Share on other sites

You can't have pages with same name. May be it is the title.

Could you share your whole find code and the for each code to list the results

Share this post


Link to post
Share on other sites

Hello Huseyin

I have many pages which share the same "PAGE NAME", but there are not on the same level. For example:

Level1/PAGE_NAME_EXAMPLE
Level1/level2/PAGE_NAME_EXAMPLE
Level1/level2/level3/PAGE_NAME_EXAMPLE

$pages->find('template=templateNAME')->pageQueryJson($query);

So for example if we had to retrieve the above example of pages I would get only one of those. I'm not sure if it gets the first or the last match.
If I change the "PAGE NAME" to something unique then I'm getting the page.

Thank you 
Spyros

Share this post


Link to post
Share on other sites

I assume based on your code above, that templateName is being used by all Page_Name_Examples?

Share this post


Link to post
Share on other sites
3 hours ago, Spyros said:

I have many pages which share the same "PAGE NAME", but there are not on the same level.

It works fine here:

2020-04-04_095428.png.2ff4b926b5206b5525a1f7e397763a80.png

3 hours ago, Spyros said:

$pages->find('template=templateNAME')->pageQueryJson($query);

pageQueryJson() is not a core method. If that method is the cause of your issue best to ask in the module's support thread.

 

  • Like 2

Share this post


Link to post
Share on other sites

Thank you Robin for pointing me in to the right direction

So as you said the issue was from the Page Query Boss module.
Actually it was not an issue of the plugin but I had to change the configuration of the output. The default output format is an array with the "PAGE NAME" as keys. Instead I used the ids as keys.

$modules = wire('modules');
$modules->get('PageQueryBoss')->defaults['index-id'] = ['Page'];
$pages->find('template=templateNAME')->pageQueryJson($query);

 

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By EyeDentify
      Hello dear PW gurus.

      I have stumbled over a strange error that i all of sudden got when trying to upload an image to a images field on a page.
      There where images allready stored in the field that i wanted to keep, but during the upload the error apear and after that all images are gone from the field and i can´t upload any, i just get the error every time.
      I am running ProcessWire 3.0.153 dev.
      Update:
      After looking in the assets folder i find the folder for the page and the image files seems to be there including the ones i tried to upload when the error occured.
      But they don´t show up in the images field in the page editor.
       
      The error reported:
       
      SQLSTATE[01000]: Warning: 1265 Data truncated for column 'ratio' at row 1 And here is a screenshot of the event:

      The TracyDebugger Error reporting:

      I hope you fine folks could point me in a direction.
      But it seems our old pal set_time_limit() is back.

      Regards, EyeDentify
    • By quickjeff
      Hi Guys, 
      I have been debugging a site for the last 2 hours and cannot solve the issue. 
      I have a site running on 3.0.148. 
      I installed the Kongondo Blog module and was updating the templates to include the website style. 
      Once everything was set and done, I checked the page tree to see an error appear. 
      Template must be assigned a name before 'filename' can be accessed
      The same error appears in templates. 
      Debugging Steps
      I checked the templates in the server to ensure I didnt accidentally delete the namespace.  Deleted cache in browser and server under assets Still no go. 
      Any help is appreciated. 
      Thanks! 
    • By benbyf
      Hi, Looking to create form elements on a page–some input with a colection of form inputs and the appropriate labels and variables for that input. I've used ProForms in the past and rolled out my own when creating simply one off forms, but I wonder if anyone has found a good way of allowing form creation on page editing so that clients can adhocly make and edit forms?
      Thanks
    • By EyeDentify
      Hello Dear PW Gurus.

      Hope you fair well in these Corona Crisis times.

      Anyhow, i have a problem with a Cryptic error message that shows up when i am trying to Delete images out of a Images field.
      The Error message does say a little but it does not make sense to me why i can´t delete the images because of it.

      Is it some permission issue perhaps?

      I will attach screenshots of it and what i did prior to it.
      I am from sweden so ignore the funny words here and there.

      Hope you all can send me on the right track.
      i am running PW 3.0.139 on this install.

      Step1:

      Step 2: Select the images with the trashcan symbol

       
      Step 3: Cryptic Error message

      I am scratching my head on this one, have not seen this before.

      Thankfull for all help.
      /EyeDentify
    • By Guy Incognito
      This short script loops through some images from an XML feed and pushes new ones to an image field. It all works perfectly, except for some reason the last image (only) in the loop each time doesn't receive the image description... can everyone spot why? TIA! 🙂 
      foreach ($propertyImages as $img) { $fileName = trim($img[0]); if ( !empty($fileName) ) { $imgPath = '../property_data/'.$fileName; if(file_exists($imgPath) && !in_array(strtolower($fileName),$currentImages)) { $p->property_images->add($imgPath); $p->save(); $newImg = $p->property_images->last(); $newImg->description = $img[1]; $p->save(); } } }  
×
×
  • Create New...