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
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 SwimToWin
      As an admin I want to use the API to ask if a page is published - using the $page->isPublished() method - so that I know it's published - as opposed to unpublished or trashed pages. That includes hidden pages.
      This method will correspond to Settings -> Status when editing pages:

      (Published is also mentioned explicitly where the edit page says "Published on [?]".)
      I would expect the API - and specifically the $page->hasStatus() method - to ask if a page has status published.
      But as I can see, it's only possible to ask for exceptions such as isUnpublished() and isHidden().
      <?php // This fails with "Fatal Error: Uncaught Error: Undefined class constant 'statusPublished'" if($page->hasStatus(Page::statusPublished)) { echo 1; } ?> PS: My current use case is that I want to count number of published vs. unpublished pages. I can only do that by getting all pages (include=all), then subtract any unpublished pages.
    • By ngrmm
      My clients wants a modal to show up on every page. But when a user clicks inside the modal -> a session-cookie is set and the modal gets a class.
      // user clicks on modal button $('.modal_button').click(function(){ // 1. set PW session cookie // 2. toggle class $('.modal').toggleClass('off'); }); I know how to set a cookie on page-load via PW-API. But the click on the modal button does not force a page-load. So i have to set the cookie through javascript. Is there a way to do that?
    • By VeiJari
      Hello,
      I'm trying to create a page via api and populate values to it. I can populate everything except user pages to a page reference array.
      Code: 
      $dataUsers = $data->project->users; foreach($dataUsers as $dataUser) { $newProject->projectUsers->add(wire()->pages->find('template=user, id=' . $dataUser->id)); } I'm receiving my data via JSON.
      Is there something I'm missing?
      Thanks for help
    • By SwimToWin
      I want to add a dependent SELECT field on my template page that lists pages from a parent "sub-page" in the current parent node.
      On /product1/page I have the field "photo" which is a SELECT field.
      I want the SELECT to list pages from /ROOTPARENT/photos.
      The idea is that I can reuse the same photo in many places - but only need to keep it update it once under /product1/photos.
      My page structure looks like so:
      /product1/page /product1/photos/photo3 (template=photos) /product2/photos/photo9 I have tried adding these Selector Strings on the Field (Setup -> Fields -> PHOTO -> Input tab -> Selectable Pages field group -> Selector String):
      parent=/product1/page, template=photos, sort=name WORKS (but only on children of current product). parent=page.rootParent ... parent=$page.rootParent ... parent=$page.rootParent parent=$parent ... parent=$parent1 When using a SELECT Input Field Type, the editing pages gives the fatal error "Unrecognized operator: $". parent=parent ... parent=. Returns an empty list How might I find child pages from the current "/product1/photos/ page"?
      Your inputs are appreciated. Thanks.
    • By VeiJari
      Hi, this is the first we are trying to make a page that has only one type of user that has access to every page. 
      The other users should only have a given access to specific pages, not to the whole template.
      My structure
      -Field -Organisation -Project -Report I want that the "measurer" role only has access to "project x" and it's children, but no view access to every project, organisation or field. I've tried to do this with https://modules.processwire.com/modules/page-edit-per-user/ but it still needs a view access to the whole tree to see the "project x" page. Or is there something I haven't figured out?
      Maybe I have to make it via the API: a select field in the "organisation" template where the admins could add the users and then I use hook to update the privileges?
      Have you done something like this and how did you accomplish it?
      Any help would be appreciated.
       
×
×
  • Create New...