Jump to content

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


Spyros
 Share

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

Link to comment
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

Link to comment
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
Link to comment
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
Link to comment
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
 Share

×
×
  • Create New...