Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Field Other Than 'title' To Be Used For Labelling Entries #1989

Closed
Undistraction opened this issue Jan 3, 2019 · 6 comments
Closed

Comments

@Undistraction
Copy link
Contributor

Is your feature request related to a problem? Please describe.
Currently entries (the list of Collection items) are labelled using that item's title field. However, this is often confusing. For example, a page might be the 'About' page, but have a title of 'There Are A Few Things You Should Know About Us'. Obviously everyone would still consider this to be the 'About' page and that would be the most correct label for that page, however with the current setup, in order for someone to find the 'About' page, they need to know the title that page uses.

Describe the solution you'd like
I'd like collections to expose a configuration parameter: entryLabel, that could override the use of the title field. That way, a hidden field can be used to track the obvious name for the page:

entryLabel: pageName

Describe alternatives you've considered
The only alternative is to use a different field for the page title so that title can be used for the short page name, however this feels wrong. Title has a clear meaning, and this is confusing.

Additional context

  • This would be a non-breaking change as it would override the default behaviour (of using title).
  • This looks like a fairly easy change. An inferredFields object is created in EntryListing and used in Entry to populate the title field. So it should just be a matter of passing in the config and using that instead of the inferred title if it exists.
@erquhart
Copy link
Contributor

We actually already have this via identifier_field, but we failed to document it where folks will actually find it. Details here: https://www.netlifycms.org/docs/collection-types/#folder-collections

Can you confirm this does what you need?

@Undistraction
Copy link
Contributor Author

@erquhart Thanks. Yes this is helpful. However it doesn't cover cases where you need a combination of fields to get a unique identifier, for example, imagine we have a 'User' collection with 'firstName' and 'lastName' fields. We need the identifier to be: ${firstName} ${lastName}, however identifier_field only allows the use of a single field. This is another strong argument for supporting interpolation of fields in field values imho.

@erquhart
Copy link
Contributor

erquhart commented Feb 3, 2019

The only place you need a unique identifier in the CMS is for slug (filename) creation, and the slug config field already supports field name interpolation.

- name: posts
  label: posts
  slug: "{{firstName}}-{{lastName}}"

If you're also referring to being able to tell entries apart in the collection view, #2019 covers that and I think we can do entry card customization in a more flexible way than interpolation within identifier_field. They're actually two very different concerns - I'd expect a dedicated template for the entry card. But we should also be showing more fields via inference in the entry card anyway, as we used to before 2.0.

@Undistraction
Copy link
Contributor Author

@erquhart Yes I was talking about interpolation as providing a way to make an entry title unique when there isn't a single field that can do this. In my example, there might be multiple users with the same first or last names, but by combining the two, a unique title for the entry can be arrived at.

@erquhart
Copy link
Contributor

erquhart commented Feb 4, 2019

Do you agree that #2019 would cover it?

@Undistraction
Copy link
Contributor Author

@erquhart I'm not sure a clear solution is proposed in #2019, but I guess it falls under the same needs - to have more control over customising what is displayed in an entry card. I see I've already mentioned the idea of interpolation in that thread, so I'll close this in favour of that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants