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 10 posts 90 karma points
    3 days ago
    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 419 posts 2264 karma points MVP 3x c-trib
    3 days ago
    Paul Seal
    0

    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 10 posts 90 karma points
    9 hours ago
    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 419 posts 2264 karma points MVP 3x c-trib
    4 hours ago
    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 10 posts 90 karma points
    2 hours ago
    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 419 posts 2264 karma points MVP 3x c-trib
    1 hour ago
    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