Render values for Umbraco.DropDown.Flexible on the front-end
Hi guys - hoping some brain cleverer than mine can help me. I have a Data Type in the CMS to categorise my News articles. Simple stuff.
I'd like to render our this on the front-end so that the user can filter the news articles. Obviously it would be ideal to get the values from the Data Type so that it's updated whenever new categories are added.
I've used the dataTypeService to do this as follows;
Which works beautifully, apart from the fact that the Data Types do not have consistent IDs when you move between environments. I was hoping this would be solved by restoring all my content from Live, but all my environments seemingly have different IDs...
For obvious reasons I'm not keen on using a hard coded ID anyway - there must be a better way?
Hi Paul, thank you so much for getting in touch (also, thank you for lots of your videos they're really helped me!).
I've had a look through the code and it all makes sense, however (stupid question coming) I've not actually built any new classes or models before, only macros and partial views etc, so I'm not sure where this code should actually live. Any pointers in the right direction would be massively welcome.
Many thanks again, Rowena
P.s. I've just noticed you're from Derby! Small world... (waves from Chesterfield).
Amazing thanks Paul - I have a couple of topics I'd really love to pick your brains on so if it's OK I'll book an hour with you... will gladly pay for your time to help save me spending days on it :)
Render values for Umbraco.DropDown.Flexible on the front-end
Hi guys - hoping some brain cleverer than mine can help me. I have a Data Type in the CMS to categorise my News articles. Simple stuff. I'd like to render our this on the front-end so that the user can filter the news articles. Obviously it would be ideal to get the values from the Data Type so that it's updated whenever new categories are added.
I've used the dataTypeService to do this as follows;
Which works beautifully, apart from the fact that the Data Types do not have consistent IDs when you move between environments. I was hoping this would be solved by restoring all my content from Live, but all my environments seemingly have different IDs...
For obvious reasons I'm not keen on using a hard coded ID anyway - there must be a better way?
Thanks awesome folks :)
Hi I wrote some code which lets you get the values from backoffice dropdowns and use them on the front end.
Here is the blog post with the code.
https://codeshare.co.uk/blog/how-to-use-a-datatype-to-populate-a-dropdown-list-in-umbraco-v8/
I hope it helps.
Kind regards
Paul
Hi Paul, thank you so much for getting in touch (also, thank you for lots of your videos they're really helped me!).
I've had a look through the code and it all makes sense, however (stupid question coming) I've not actually built any new classes or models before, only macros and partial views etc, so I'm not sure where this code should actually live. Any pointers in the right direction would be massively welcome.
Many thanks again, Rowena P.s. I've just noticed you're from Derby! Small world... (waves from Chesterfield).
Hi Rowena
Wow Chesterfield is very close, it is a small world.
I can show you how to do this over zoom if you like. Check out https://codeshare.co.uk/coaching
Message me on Twitter if you’d like to talk more about it or just book one of the free 15 minute slots.
Paul
Amazing thanks Paul - I have a couple of topics I'd really love to pick your brains on so if it's OK I'll book an hour with you... will gladly pay for your time to help save me spending days on it :)
Great looking forward to speaking to you.
At the moment I just have this week available. Ideally it would be good if you could book towards the beginning or end of a day.
Kind regards
Paul
is working on a reply...