Sign in to follow this  

Searching fot term in repeater.

Recommended Posts

I'm having problems with seatching for a value in repeater.
One of pages have attached repeater called 'insight_repeater'.
This repeater has h1_tag (text field) and i'm trying to search for repeater items that contains 'lor' phrase.

And right now i'm trying to do simple search, looking for phrase 'lor'. I've tried many approaches, but nothins seems to work, so i want to ask what i'm doing wrong here:

<?php $query = $page->get("insight_repeater")->find('h1_tag~=Lor'); ?>

Thanks for help.

Share this post

Link to post
Share on other sites
3 minutes ago, kixe said:

Hi @kixe !

Thanks for fast reply, but what is the difference between those two as both uses $pages ? (not $page and $pages).
get() will get repeater from current page, and find() will search in whole project ?


Share this post

Link to post
Share on other sites

I've just checked this.
first case returns:
noticee: trying to get property on non object in...

and the second returns nothing ...
I'm using latests dev version.


Recently, i see that my code is actually working, but if h1_tag contains "Lorem" i'm only able to make this work if i'll type:

<?php $query = $page->get("insight_repeater")->find('h1_tag~=Lorem'); ?> and not Lor. Is there any workaround ?

Share this post

Link to post
Share on other sites

One strange thing is:

This page, that containes insight_repeater also have h1_tag, and this query will return page's h1_tag instead of repeater's h1_tag:


<?php $query = $pages->find("insight_repeater.h1_tag~=Lorem"); ?>


Share this post

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

<?php $query = $page->get("insight_repeater")->find('h1_tag~=Lorem'); ?> and not Lor. Is there any workaround ?

Welcome to the forums @activestate

Have a read here about selectors, specifically about MySQL and short words.


The *= and ~= rely upon MySQL fulltext indexes, which only index words of at least a certain length (configurable, but typically 4 characters). They also don't index common English words called stopwords. So while it's preferable to use *= and ~= for their speed, if you aren't getting the results you need, you should consider using %= instead (if you can handle the speed hit).


Please use code blocks (@see the <> icon) around your code.

  • Like 3
  • Thanks 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

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By theoretic
      Hi there! And thanks for Processwire!
      This is rather a question than a feature request, maybe there's a well known solution which i missed.
      So what about aggregation in selectors? Let's suppose we have a PW-powered shop where any product has a rating made by customers. Every time the user polls two data fields are updated: points and votes. The rating is calculated as this:
      $rating = $page->points / $page->votes; It was easy, yeah. But what about sorting products by their rating? Basically there are two ways of doing it:
      Creating one more field called rating and updating it after every vote. For sure it will work, but we have to create an extra data field which in fact stores data based on two another fields. Bad practice i think. Getting all products into array and applying a cutom sort function. Will work again, but this demands much more coding than using the native PW selectors. But how could it be done in the best possible way? Let's imagine this:
      $products = $page->children("sort=points/votes"); Or maybe this:
      function rating($a,$b){ return $a->points/$a->votes > $b->points/$b->votes; } $products = $page->children("sort=rating()"); Okay, let's go even deeper. Maybe we need "virtual" fields which are not stored in DB tables like other PW fields but represent the dynamically calculated values?
      $page->rating = function(){ return $page->points/$page->votes; } $products = $page->children("sort=rating"); Will be glad to see advice on the best practices. Thanks in advance!
    • By prestoav
      Hi all,
      I'm having an odd issue that I think is down to the selector I'm using but I can't track down the cause!
      I'm using front-end AJAX search form on a list of product adverts (pages)  where the product is made by a certain manufacturer (vendor). The manufacturer is chosen buy the person listing the adverts from a page field list of manufacturers who's parent is id=1034.
      Most manufacturers are being found without an issue. The only one that's causing a problem is called 'Proj-ect" (the "-" being part of their brand name.
      Here's my selector code:
      $thisBrandProducts = $pages->find("template=advert,vendor.title~=$q,has_parent=1034,limit=20,created_users_id!=$susDealerList"); $susDealerList is a list of advertisers that are not currently live so pages should be excluded.
      Could the "-" in the name be the issue with those pages not being returned? If so does anyone have any ideas of how I can get around this?
      Thanks in advance!
    • By j00st
      Hi everyone!

      Perhaps I'm a bit enthusiastic in using the Repeater-field & FieldsetOpen combo, as I've already posted another question about it today...
      But here goes nothing
      I've got a FieldsetTabOpen which I'm using in a Repeater-field, but that's not working as expected; as in – no tabs showing 
      Instead it just shows the two grouped in FieldsetTabOpen below each other...would be great to see tabs in the repeater as well.

      To add some visuals in; In the attached images the fluor-green box is my repeater, with two checkbox fields, and after that the two FieldsetOpenTab groups.
      The other two are how I set up the fields in the repeater (Reno AdminTheme) and the current view in the CMS.
      Any tips/recommendations as to how I could go about setting this up? I've tested the FieldsetOpenTab elsewhere, it works perfectly – but then again, here I'm trying to use it in a Repeater instead of directly in a template....would I need to place the two tabs in a fieldset? Or some other ingenious construction-ideas that could help out here? Hope someone has an idea as to how to do this! Thanks!

    • By GWColeman

      I am working on a processwire project for my college. I created an entire site about a year ago without any problem. Today however, I was making some changes to the site and I was experimenting with duplicating data across multiple pages. There is a repeater on one of the pages that I need to be the same across all pages.

      I clicked the checkbox to autojoin within the field options for the repeater and processwire crashed. I am not able to make any changes to the page to uncheck and I cannot view the site any longer.
      This is the message I get on the page.
      Fatal error: Exception: Could not execute User::__construct() (in /var/www/html/wire/core/Pages.php line 323) #0 /var/www/html/wire/core/Pages.php(323): mysqli_result->fetch_object('User', Array) #1 /var/www/html/wire/core/PagesType.php(101): Pages->getById(Array, Object(Template), 29) #2 /var/www/html/wire/core/Session.php(64): PagesType->get(41) #3 /var/www/html/wire/core/ProcessWire.php(138): Session->__construct() #4 /var/www/html/wire/core/ProcessWire.php(46): ProcessWire->load(Object(Config)) #5 /var/www/html/index.php(185): ProcessWire->__construct(Object(Config)) #6 {main} in /var/www/html/index.php on line 217

      I tried to comment out 323 without any luck. I also took a look in the database to see if I could manually turn off the autojoin option. However, I was not able to figure out where the option was located within the database.
      Any help or suggestions would appreciated.
      I was able to solve the issue on my own. I did a google search and found that I needed to change he flag for the field from 1 to 0 in the database, and everything works again.

      Here is the post that I found that solved the issue.
    • By theoretic
      Hello there! And thanks for Processwire!
      It may appear a noob question but what about selectors like "field1=val1||field2=val2"? I mean that the page we're looking for should have field1=val1 OR field2=val2 . There's plenty of examples for cases like "field=val1|val2" but it's another case.
      Practical example: frontpage uder registration. User should enter nick and email, and both of them should be unused by other registered users. It's logical to use something like
      $userTest = $users->get("nick={$input->post->nick}|email={$input->post->email}"); But this doesn't work.
      That's the best practice in this case? Thanks in advance!