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

Adding values programmatically through Views is bad practice #5533

Open
Migaroez opened this issue Oct 18, 2023 · 4 comments
Open

Adding values programmatically through Views is bad practice #5533

Migaroez opened this issue Oct 18, 2023 · 4 comments

Comments

@Migaroez
Copy link
Contributor

What type of issue is it? (Choose one - delete the others)

Bad practice promotion

What article/section is this about?

(multinode-treepicker)

Describe the issue

We shouldn't be promoting back practices like injecting core services into templates as this can lead to people using the services for content fetching

We should also try to tell a story with a code example and make it as close to a good practice example as possible (no hard coded id's)

@skttl
Copy link
Contributor

skttl commented Oct 19, 2023

I somewhat agree, but that is how every "how add values programmatically" is done. https://github.com/search?q=repo%3Aumbraco%2FUmbracoDocs%20programmatically&type=code

@alina-tincas
Copy link
Contributor

alina-tincas commented Oct 19, 2023

Hi @Migaroez thank you for bringing this to our attention. In order to understand the issue better, can you elaborate more specifically on what you would like to change in the documentation and where (if you have a specific content part in mind)? 🙏

@erikjanwestendorp
Copy link
Contributor

@Migaroez @alina-tincas @skttl I agree that the way this is currently done is not the best example, and we should prevent it from being adopted. I believe it was chosen at some point because it's a simple way to demonstrate how values can be added from code. As @skttl also points out, this has been done in the same way for all property editors, so if any adjustments are made, it should actually be adapted for all property editors to maintain consistency.

One option could be to create examples, for instance, from an API Controller (perhaps there are better scenarios as well?). Of course, we can also add a note indicating that this should not be done from a view, but it was done to quickly and easily illustrate how values can be added from code.

@sofietoft
Copy link
Contributor

Hi there 👋

It looks like this discussion has gotten a bit stale over the past 6 months.
I've been looking into the issue being discussed here and I agree that we shouldn't be promoting bad or not recommended practice in our documentation!

I also agree, that the samples we use in our documentation like this should ideally be telling a story, or at least use some sort of "real life" example. However, how we go about this is not super clear to me at the moment.

One of you suggest using the API controllers, which would also be my go-to if I had to rewrite the samples.
But... these are deprecated and will be removed from Umbraco 15, right?
At least, that is what we're saying in this article: https://docs.umbraco.com/umbraco-cms/reference/routing/umbraco-api-controllers - I might be wrong!

I will take this up internally here at Umbraco HQ after the summer holidays, in order to decide how we want to showcase creating content programmatically going forward.

Until then, I like the idea of adding a little note about how we're currently using the Views as a quick way to illustrate how values in content can be added/updated from code! So let's do that as a start💪

@sofietoft sofietoft changed the title MultiNode treepicker needs some love Adding values programmatically through Views is bad practice Jul 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants