Jump to content
Mike Rockett

Excluding repeaters from $pages->find()

Recommended Posts

Greetings :)

I'm new to PW, and think it's fantastic! Never, ever, have I seen such an amazing CMF!

Anyways, to my question: I had set some Hanna Code to render a list of page suggestions on the http404 page, which works perfectly. The problem, however, comes in when I use repeaters, which are page instances.

The page suggestion renderer has the following:

    $suggestions = $pages->find('name|title|summary|body%='.$request);

I have a page that is named services-industries, and repeaters with the word services in the name. As such, repeaters appear in the suggestion results-list if applicable to the search.

How can I exclude/remove those?

Share this post


Link to post
Share on other sites

Welcome! Repeaters shouldn't be there, since they are hidden. Do you have include=hidden in selector also?

Also do you really need the name in the selector?

Share this post


Link to post
Share on other sites

Hi :) No, I don't have any selectors like that.

I thought that since I'm searching for suggestions based on the request (which is the name), that I should also be searching for others by name as well. Nonetheless, if I remove name from the query, I still get the repeaters.

Though, I've just noticed that they only appear when I am logged in. Each repeater contains a link to itself in the backend. But when you click on it, it says that there's no Process for this. This is an example URI: /administration/repeaters/for-field-136/

Anyways, if I'm logged out, it's cool. Perhaps there's a bug, or was it like that intentionally?

Share this post


Link to post
Share on other sites

I've noticed the same thing: when logged in, all repeaters are included in the search results. I don't know if this is ok, or if there's a reason. It looks weird to me :mellow:

Share this post


Link to post
Share on other sites

A temporary fix would be using this"!template^=repeater_", but maybe someone should file a github issue, so Ryan can take a look at it. 

Share this post


Link to post
Share on other sites

Repeaters are stored in admin with own template not "admin" template, so a logged in superuser see's them but others not.

it's not a bug. You could exclude admin or by template if you want superuser not see them.

has_parent!=2

  • 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 VeiJari
      Hello forum, we're trying to use Processwire as our REST-API. We are having problems with our API login to Processwire from frontend. It gives us 403 error.
      We have installed ProcessWire to subdirectory (/api/*) and our frontend is static JS files at root ( / ). Apache access logs gives 404 to our POST-request, but browser devtools shows 403 for our POST /api/login request. 
      Processwire backend panel works. We also have a GET endpoint for the API that returns 200 with correct payload.  So we're wondering why does our GET works but POST doesn't?
      Does this have something to do with Processwire .htaccess, or is this because of our webhost? What should we check first? Any help would be appreciated.
    • By Peter Knight
      Hi 
      I have a list of pages all based on the same template but I want to exclude 2 by page ID
      $expertises = $pages->find("template=case-type, sort=sort"); foreach ($expertises as $expertise); I know I could change their template or add an exclude checkbox to the template etc
      Wondering if there is a page=not(4989,9877) type of thing in the API to exclude pages by ID?
      I can't find anything in the API docs but think I may be searching for the wrong phrase.
      Thanks
    • By rjgamer
      Hi,
      is there a hook after the current (active) page got created? Or which method got called in the Page class after the Constructor of the current page got initialized?
      Thanks.
       
    • By killedfriendz
      I am very sorry for asking this but i totally do not understand how to set values of checbox using API. 
      I have checbox field on my page with name "order_status". 
      So i've tried few ways to make it checked but it still doesn't work:
       
      $userPage->order_status->value = 1; $userPage->order_status->add(1); $userPage->order_status->add(true); Could you please tell me how to do it?
    • By rjgamer
      Hi guys,
      the field "redirect_last" of type DateTime got not updated. The update on the field "redirect_counter" works and got saved.
      Does anybody know what I did wrong in my code?
      if ($input->urlSegment(1) === 'redirect') { $page->of(false); $page->redirect_last = time(); $page->redirect_counter += 1; if ($page->save('redirect_counter')) { $session->redirect($page->website_url, 302); } } Thanks.
×
×
  • Create New...