Copied to clipboard

Flag this post as spam?

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


  • Maarten Mensink 2 posts 52 karma points
    Sep 22, 2014 @ 16:35
    Maarten Mensink
    1

    Carousel with Extended options

    Hello community,

    My first post(thanks to the persuasion of @cultiv) so please be gentle ;)

    I have a quick question regarding using media type of document type to setup a Carousel(based on the bootstrap carousel). I searched for some solution but didnt find anything matching my requirements.

    Requirements:

    1. Carousel data should be reusable.
    2. Need to define a image / title / description / call to action(title and url) per carousel item
    Reading up on how Umbraco defines structures to store info i first decided to use a Document Type(based on this post) but this gave me a creepy feeling as Umbraco generates a link to the document. So i decided to use a Media Type.
    I have created the following media types.
    1. Carousel(Meta data for the entire carousel / can contain type Carousel Item)
    2. Carousel Item
      Properties
        - title(textstring)
        - description(textstring)
        - Image(Media Picker)

    With this i am able to define the content of a Carousel and its items. In a document i could now add a property Carousel of type MediaPicker and select a Carousel. Which you easily can pass on to a partial to render a carousel.
    @if (Model.Content.HasValue("carousel")){
        var carousel = Umbraco.TypedMedia(Model.Content.GetPropertyValue("carousel"));
        @Html.Partial("Carousel", carousel) 
    }

    So the feeling that i'm horribly abusing media type didnt go away after a few days. 

    The question is. Is this the right way or should i go back to start and try again :)

     

     

  • Sebastiaan Janssen 5058 posts 15520 karma points MVP admin hq
    Sep 22, 2014 @ 16:50
    Sebastiaan Janssen
    0

    Your first solution was also absolutely fine: if you don't give the document type a template then going to the generated URL will create a 404. The first option is actually exactly how we teach it in the courses.

    However, your second solution is also valid and I guess more semantically correct (ie: you're not creating media items in the content section). The only problem with this approach is that the drag & drop upload creates items of media type Image by default (and there's no way to change that). So maybe a better approach for the editors is that you change the media type Image to include the fields you want (and the title could just be the name of the media item). Then they can just drop in the images without having to pick them from somewhere else.

    So.. as with a lot of things in Umbraco: it's up to you, whatever you feel more comfortable with!

  • Maarten Mensink 2 posts 52 karma points
    Sep 22, 2014 @ 17:18
    Maarten Mensink
    0

    @cultiv thanks for the quick reply. 

    I get the point but lets talk some semantics. If the point of a document is to be displayed as a page(seeing that all content that is created based on a document type gets a url) isnt it a bit strange to create content that will generate a 404. 

    What is the point in having a url if it will fail. It just feels wrong. Semantically a carousel isnt a MediaType either but more likely a ContentType. It would be nice if one could create Content that isnt based on a DocumentType or MediaType but based on a ContentType.

    Is that possible or is it wishfull thinking? 

    footnote: i'm a nutt for opinionated software :)
  • Sebastiaan Janssen 5058 posts 15520 karma points MVP admin hq
    Sep 22, 2014 @ 17:57
    Sebastiaan Janssen
    0

    Isn't it normal to render a 404 when there's nothing else to render?

    A documenttype is a contenttype, so is a mediatype by the way (same base class). If I'm not mistaken, we could actually generate a url for each media item as well, it's just not exposed in the UI, plus there's never a template attached to a media item. Now, if you want to be very precise about it: we shouldn't show a URL to click on when there's no template attached. FYI: the fact that there is a URL does not mean that it's "created" anywhere, the url is simply based on the document's name and not stored anywhere.

    Opinionated we're in some areas, in most areas Umbraco is a nut for helping developers move on with whatever solution they themselves are opinionated about. :) It's a very flexible framework and that's what people love about it.

Please Sign in or register to post replies

Write your reply to:

Draft