Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Rowena Bellamy 17 posts 118 karma points
    Jul 31, 2020 @ 13:06
    Rowena Bellamy
    0

    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;

    IDataTypeService dataTypeService = Services.DataTypeService;
    
    IDataType dataType = dataTypeService.GetDataType(xxxx);
    

    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 :)

  • Paul Seal 524 posts 2889 karma points MVP 7x c-trib
    Jul 31, 2020 @ 22:35
    Paul Seal
    100

    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

  • Rowena Bellamy 17 posts 118 karma points
    Aug 03, 2020 @ 06:42
    Rowena Bellamy
    0

    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).

  • Paul Seal 524 posts 2889 karma points MVP 7x c-trib
    Aug 03, 2020 @ 11:19
    Paul Seal
    0

    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

  • Rowena Bellamy 17 posts 118 karma points
    Aug 03, 2020 @ 12:59
    Rowena Bellamy
    0

    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 :)

  • Paul Seal 524 posts 2889 karma points MVP 7x c-trib
    Aug 03, 2020 @ 13:21
    Paul Seal
    0

    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

Please Sign in or register to post replies

Write your reply to:

Draft