Search

How's your PHP? Try modifying it so that it checks both handle and value.

It checks the handle already... or am I missing something?

Yeah, handle checks usually work, but this is an interesting scenario because the characters that are stripped to create handle's also include identifying characters in regards to emails.

As @into mentioned, two email addresses john_doe@yahoo.com and john@doe-yahoo.com would both evaluate to the same handle, john-doe-yahoocom, so the Field would throw a false positive as they'd both be determined to be the 'same'.

@into, what if you used the Auto Unique setting and did all your filtering using value instead of handle syntax?

Ah ! that would likely work perfectly, I'll try. thnx @brendo

No go, it just adds them without an error and gives them a unique handle.. Ideally it simply wouldn't add the duplicates.

Great idea @nickdunn ..
Hey community ! Here's a version that checks against value, not handle :)
Replace field.uniqueinput.php with this file.

I don't understand something... I created 3 entries called "test" with the unique text input field. Then I try to use this field to filter the datasource, to display the content of a single entry.

When the value of the url param is "test-1" no result, right it should be "test" to display the first entry "test-2, test-3" perfect result, i got the content but "test", still return the "test-3" value, so my first entry is not accessible.

Did i made a mistake configuring the datasource filter?

I am trying to use a DS filter on email addresses (Unique Text Input field in section 2, datasource 2) using domain names (section 1, datasource 1).

The param output of datasource 1 correctly shows 2 domains. But when I filter datasource 2 using regexp:@{$ds-domains}$, I only get email addresses for the first of these domains.

My question is: Is this a known limitation? Will regex filtering not work with multiple values? Is it a limitation of the Unique Text Input field? (Or am I just doing it wrong?)

Try taking the @ off and see if that works?

I already tried to no avail. :-(

That works, BTW:

regexp:@example.com|@anotherexample.com$

But that just outputs addresses for the first domain:

regexp:@example.com,@anotherexample.com$

I verified that it does not work with the standard Text Input field either. So I am afraid that I am doing it wrong. :-(

Obviously params with multiple values are not "processed" before creating the query. (I am not even sure if they should be.) So I may have to create a custom DS.

Using SymQL, I solved the issue. That's basically what I did in the grab() function of my custom DS (using an array of domains):

$query = new SymQLQuery($root_element);
$query
    ->select($field)
    ->from($section)
    ->where($field, 'regexp:'.implode('|', $domains).'$')
    ->orderby($field, 'asc')
    ->perPage(2000)
;
$result = SymQL::run($query, SymQL::RETURN_XML);
return $result;

Hey, it's a bit of a shame that this can't be done without an extension.

Yeah, but thanks for sharing how it worked, that solves a problem I've avoided for a concept site.

I think there is talk of getting SymQL in the core at some point, although I may be wrong.

I remember now that I had a lengthy discussion with Brendan about regex filtering, and it was difficult to do with an or operator (,). If I remember right, the outcome was that filtering for fields was going to drastically change in it's implementation, and that Rowan and Brendan were working on a concept to remove this from fields themselves and have them subscribe to filtering methods.

Would have been helpful to remember that yesterday :(

FYI: I found a second solution which may be interesting as well. I created two standard datasources, one for the domains (let's say it's called "Domains"), a second one for the email addresses. In the second DS I added the following to the grab() method:

// Custom regex filter
$domains = $param_pool['ds-domains'];
$this->dsParamFILTERS['6'] = 'regexp:'.implode('|', $domains).'$';
//

The second DS needs a dependency, which will for example be created for you if you add the param $ds-domains as a required param. You should, of course, make allowEditorToParse return false.

I'm trying to install ver 1.3 into sym 2.3 but get this error when I try to enable/install...

Fatal error: Call to a member function query() on a non-object in /home/jeffstreet/webapps/jeffstreet_forsale/extensions/uniqueinputfield/extension.driver.php on line 22

Any ideas?

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details