Search

A new Extension, “Unique Text Input Field” is now available for download. Comments and feedback can be left here but if you discover any issues, please post it on the issue tracker.

This works identically to the normal text input field, however it will force handle uniqueness by either throwing an error, or adding a number to the end of the handle to form a unique handle. The behaviour is set when adding the field to a Section.

Many thanks to Airlock for funding the development.

Requires Symphony 2 Beta Revision 5

Check out a copy from Github: http://github.com/pointybeard/uniqueinputfield

Changes

1.3 - Fixed logic behind automatically creating unique handles.

1.2 - Fixed ordering. Will no longer cause invalid SQL to be generated.

1.1 - When checking uniqueness, field will no longer include itself, preventing errors when contents didn't change during an edit.

Updated to v1.2

There's a weird behaviour with this field: the handle is re-saved upon updating, but the number at the end of it is calculated wrongly, I think. If you save your entry the number toggles between the correct number and (correct number)+1. Weird, and quite hard to explain, but you can try it yourself.

Anyway, if you too have this problem, I've found that including itself in the WHERE clause is the solution of the problem, but only if we're updating stuff, not inserting new entries. For example:

$where = ($entry_id) ? " AND `entry_id` != $entry_id" : "";

and then add the $where variable in the WHERE clause of the query at line #131.

By the way, with this fix, if the contents don't change, the handle won't change as well.

Can anyone confirm this? Thanks!

Thanks for spotting that andre

I've Posted some fixes, and tagged v1.3. Have a look here: http://github.com/pointybeard/uniqueinputfield

installed it, checked “Create unique handles automatically” and when i add 2 entries with the same title the first one’s handle is correct but the second one is blank

<entry id="120">
    <title handle="">test</title>
    <date time="08:43" weekday="1">2009-09-28</date>
</entry>
<entry id="119">
    <title handle="test">test</title>
    <date time="08:43" weekday="1">2009-09-28</date>
</entry>

anyone had this problem before?

There’s a similar bug report on GitHub, but I haven’t tried this out for a while. I hope Alistair finds the time to look into it.

Fixed, pull request sent.

Aha, consider it Dunn. :-)

Thanks a lot, Nick!

nice!

i try to change Text Input with this Unique Text Input field. So, create a new Unique Text Input field with name of previous Text Input Field (rename this one), and retype titles to new field, but then get a mistake, that such a page not found. What's wrong?

but then get a mistake, that such a page not found

In the Symphony backend, or your website frontend?

in the frontend. I look at my page

Sorry

Couldn't find what you were looking for. But have you seen our spiffy home page?

instead of its real content

Ah, you will probably need to rebuild your data source filters to use the new field.

Does this with with unique emails?
That's what I need it for, but I don't think it will work, because..

john_doe@yahoo.com => john-doe-yahoocom

is the same as

john@doe-yahoo.com => john-doe-yahoocom

Pretty sure it only checks whether or not the handle is unique, not whether or not the input is unique.

Riiight, so is there any way to do unique emails ?

Give it a try and find out is my suggestion... :)

Give it a try and find out is my suggestion... :)

Yes. Try it. If it doesn't work then ask again.

Per my example above it doesn't work for this use-case :(

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