Search

A new extension, "Slug 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.

Very nice, I've always had to rely on a SternWarning™ to editors not to change the title once set, but being able to have Symphony enforce it is great! Will definitely be using this :)

Tested it on a test/development install I have and everything seems to work fine, apart from... I had to change the id attribute in extension.meta.xml to slug_field in order for the extension to show up in the System > Extensions listing. Filed an issue on Github.

The only other thing I might suggest is renaming your github repo to slug_field so that when users are installing as a git submodule via the symphonyextensions.com website quick links we don't have to manually rename the folder/destination - it's totally a minor point though so feel free to ignore this request :D

Bravo on your first Symphony extension!

Thank you very much for the issue and the explanation of the naming convention. Lot of firsts here, so I really appreciate the help!

Essentially this is still just a VerySternWarning™ because I don't actually prevent changing the slug in the PHP. A little DOM manipulation and you can still change it, but it shouldn't happen by accident or due to lack of understanding (hopefully).

What is the expected behavior when the field is not required?

I presumed it would automatically create a handle based on the "existing field to mimic" but it throws this error: Column 'value' cannot be null

If I set it to be required then the user must manually enter the slug (he can't even copy paste the title - he must write it like an url).

Thanks

@roalex82 - I'll admit I didn't do much with non-required fields as I didn't see a lot of need for a slug you can't count on. Are you saying that the slug field is not required in your case, or that the "existing field to mimic" is not required? Or both? Thanks.

Edit: I made some changes which should allow copy-pasting by mouse and for the slug field and the field it is based on to be left blank. More clarification on what behavior you are looking for with the automatic handle would be helpful. In that situation is the "existing" field required and the slug is not?

@sarahkemp - I don't understand what's the "Handle of existing field to mimic" purpose. For example I have a 'title' text input field and a slug field with the handle of existing field to mimic set to 'title'. When I create a new entry if I write something in 'title' and nothing in slug it doesn't work (if slug is required it tells me so and doesn't save, if slug is not required it throws the error Column 'value' cannot be null).

So if the author has to write the slug manually than what does "Handle of existing field to mimic" do? My impression was that the slug would take the handle from 'title' and make it read-only after "Create entry".

Thanks

You understand correctly. If I make a section 'Test' with a text field 'Title' (handle is title) and a slug field 'Slug' with the 'handle of existing field' set to title, then when I type in the Title input of a new entry, the slug field auto-fills based on the contents of the Title field. Once I save the entry the slug field will switch to readonly.

Are you seeing javascript errors on the page when you add an entry? Can you check to see if the javascript is being added to the page? (slug_field.js)

I'm sorry this isn't working for you.

I found out the problem. I was testing in a subdirectory and the extension was looking for the js asset in root. This should fix it in extension.driver.php:

Administration::instance()->Page->addScriptToHead(URL . '/extensions/slug_field/assets/slug_field.js',time()+1);

Basically it adds URL . before the path.

Thanks, great extension!

Ah, thanks for figuring this out @roalex82! I will add that to the repo.

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