Hi all

Fairly new to using ECK really helpful thanks in advance.

Just one small issue for me right now. When I create a new Entity Type and add a name Machine-readable name (A unique machine-readable name. Can only contain lowercase letters, numbers, and underscores.) is the message in the admin.

The problem is I can't add a - (dash) to the name. This means all my urls (addresses in the browser) all have a underscore.

Example:
whats on = entity type
events = bundle
example.com/whats_on/events

What I'd really like is:
example.com/whats-on/events

Isn't there a way to add - instead of _ ?
Or a way to change the address so things are more user friendly?

Thanks for any guidance,
Barry

Comments

computerbarry’s picture

Can anybody help with this?
Is this a bug, a feature something we can fix?

Thanks, Barry

fmizzell’s picture

@computerbarry Thank you for bringing this up. I do think that it is some sort of unspoken rule to use - instead of _ for urls. I think we could make that change. I am currently trying to get an alpha for 3.x out, so I will probably not have time to concentrate on this, but if you would like to submit a patch with the fix that would be great :)

fmizzell’s picture

Category: Support request » Feature request
Priority: Normal » Minor
nevets’s picture

The underscore is valid in a PHP variable name, the dash is not. So that is why machine names use the underscore. I believe content types translate the underscore to a dash when generating paths.

computerbarry’s picture

I do think that it is some sort of unspoken rule to use - instead of _ for urls.

Absolutely fmizzell. Very surprised this wasn't thought of at first.

...but if you would like to submit a patch with the fix that would be great

I wish I could. Still very much a new Drupal Developer so slightly out of my skills right now.

Would be great if we could add this into one of the next releases or if anybody has time to create a patch. Brought one of my projects to a halt unfortunately have to use some sort of work around. Less words, no spaces :(

Thanks for getting back and look forward to any new releases.
Good work!

Thanks, Barry

computerbarry’s picture

I believe content types translate the underscore to a dash when generating paths.

Correct nevets. But how do we now translate this with Entity Types?

Another question I have is: Can we hide the Entity Type name altogether and just show the bundle name in the url somehow?

Barry

UPDATE
Until things get updated, hopefully in the next release. I suggest the Pathauto Entity Module I've set this up without any problems, Pathauto's side kick for Entities :) https://www.drupal.org/project/pathauto_entity

robloach’s picture

Status: Active » Closed (works as designed)

I don't believe we'll be supporting `-` in there as it's a machine name.