Jump to content

Selector *= working for field on one template but not another


Rob
 Share

Recommended Posts

Good afternoon.

I have a strange issue whereby I have a custom-coded FieldtypeTags field named "tags" that is comma-separating values and storing them in the DB.

Against one set of pages with a template with "tags" field call I seem to be able to do $page->children('tags*=sometag') with no issue but on against different template that contains the same "tags" field I get the following error:

WireException: Operator '*=' is not implemented in FieldtypeTags (uncaught exception)

I am not aware that I have done anything different in either case, they are simply 2 different templates that both contain the same "tags" field, one which responds to this search criteria and and one that gives me the error.

I have checked the DB and there is a value stored in the field_tags DB table against the page I am trying to select.

I'm out of ideas - any suggestions?!

Link to comment
Share on other sites

I think the answer lies in your FieldtypeTags module. Unless it extends FieldtypeText and inherits the capabilities of FieldtypeText (which includes support for the *= operator) then you will get the error saying that the operator is not implemented. As for why it works in one instance and not another, I have no idea without seeing the code behind the module. But just wanted to mention that operators like "*=" and "~=" and "%=" are not something that Fieldtype knows about natively – your module has to implement them instead. The good news is that it's very easy to do, and PW even provides a helper class to do it for you. See here in FieldtypeText for an example. You'll also need to make sure your Fieldtype's schema uses a fulltext index. 

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...