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 neonwired
      I have a front end form for creating new pages, repeater and repeater matrix field don't seem to save any data. I was considering handling the data manually but can't seem to get anything useful from the post data, are there any methods i can use?
    • 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 Spyros
      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
    • 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 t0b1
      Hello there, and thanks for ProcessWire!
      I'm getting to know ProcessWire while doing my first project using it and I really like it so far.
      The challenge I'm facing right now is the following:
      I have a One-Pager using fullpage.js, realized as a single PW-Page containing a Repeater Field where each Repeater Item is one Section.
      Some Sections are supposed to have a little menu at the Top which references/links to different Sections of the Website, so I wanted to use a Checkbox Field "Top Menu" to decide if a Section gets a Menu and a Page Reference Field to choose the different Sections (Repeater Items) it should contain.
      I've already accomplished this by pasting the following code into /site/ready.php:
       
      $wire->addHookAfter('InputfieldPage::getSelectablePages', function($event) { if($event->object->hasField == 'top_menu_entries') { $page = $event->arguments('page'); if($page instanceof RepeaterPage) $page = $page->getForPage(); $event->return = $page->; } });  
      The only problem that still remains is that when I select the Entry of the Repeater Item itself it doesnt save the selection, meaning after I saved it's unselected again.
      On some Sections I do want a Menu-Entry for the Section itself though (which would be styled differently and not link anywhere) for Continuity-Reasons, any ideas on how to achieve that?
×
×
  • Create New...