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

Relation widget: store related item's slug value in valueField #1063

Closed
criticalmash opened this issue Jan 30, 2018 · 12 comments · Fixed by #3659
Closed

Relation widget: store related item's slug value in valueField #1063

criticalmash opened this issue Jan 30, 2018 · 12 comments · Fixed by #3659

Comments

@criticalmash
Copy link

- Do you want to request a feature or report a bug?
feature

- What is the current behavior?
The relation widget's valueField allows you to specify a field in another collection as a lookup value for items in that collection. The sample case given is the related item's title.

- label: "location"
        name: "Location"
        widget: "relation"
        collection: "locations"
        searchFields: ["title", "streetAddress"]
        valueField: "title"

- What is the expected behavior?
I would prefer to store the related item's slug/filename in the valueField instead. This would allow me to easily lookup and include the file or it's data when generating the site.

Also, by using the filename, CMS can provide some guarantee that keys are unique.

- label: "location"
        name: "Location"
        widget: "relation"
        collection: "locations"
        searchFields: ["title", "streetAddress"]
        valueField: "{{slug}}"

With this type of config, I can load in a collection of files as a JS object and lookup an item by it's slug.

var locationSlug = frontmatter.location;
var locationData = locations[locationSlug];

- Please mention your CMS, node.js, and operating system version.
CMS v1.1.0

Thanks,
John

@tech4him1
Copy link
Contributor

This will be much easier once the slug is a separate field: #445.

@criticalmash
Copy link
Author

Thanks @tech4him1 I've subscribed to that issue.

@robsonsobral
Copy link

As I pointed on #445 , slug and filename isn't necessarily the same thing.

(I'm really looking forward to use the filename as valueField.)

@amykapernick
Copy link

Is there any update on this? I'd like to use the slug as a value field as well

@erquhart
Copy link
Contributor

erquhart commented May 9, 2019

Not yet, but the general slug handling story is very much on the radar.

@stale
Copy link

stale bot commented Oct 29, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@tobytraylor
Copy link

I'd like to use the slug as the valueField as well.

@schjetne
Copy link

schjetne commented Apr 15, 2020

This issue is kind of killing Netlify CMS for me right now. I organize the articles like this: {{topic}}/{{slug}} and topic is a relation field. As it is right now I can’t do what I had planned because I cannot expect the users to make a manual “slug” for all topics in the site.

This issue has been open for two years and looks like the most requested feature in the whole system. What is the progress looking like?

(Yes, I realize I’m getting impatient with free software…)

@erezrokah
Copy link
Contributor

Hi @schjetne, we try to get to the most upvoted features first. This one is ranked as number 9 per this sort: https://github.com/netlify/netlify-cms/issues?q=is%3Aissue+is%3Aopen+sort%3Areactions-%2B1-desc
You could up vote it so it get more visibility.
Regardless we are always open for contributions.

@schjetne
Copy link

Thank you! Upvoted. I found a hacky way of solving this, but will eagerly await updates so I can delete my work-around when the relation slug finally arrives.

@dopry
Copy link
Contributor

dopry commented Jul 8, 2020

@erezrokah how does #3659 close this issue?

@erezrokah
Copy link
Contributor

Hi @dopry, you can now configure valueField: "{{slug}}".
See the second example here https://www.netlifycms.org/docs/widgets/#relation

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

Successfully merging a pull request may close this issue.

9 participants