can we reuse / read out the dropdown values of a filed of a content type in razor ?

Apr 16, 2014 at 6:46 AM

I have the following portfolio display made with 2sexycntent

its a filterable portfolio and the
are options in a dropdown display of the category input field

right now I put this as a list presentation in pure html

that works but oudl need to be updated if that field in the content type is also updated.

Is it possible to in razor get the content type and from that content type get the values of the dropdown fields and then cycle through that to build up my html ?

Apr 23, 2014 at 12:03 PM
yes, you can do this, but a bit differently...

the field definition is not accessible - so if the choice-list is only in the input-field definition, it won't work.

what you want to do is create a different content type "Category" or "Tag", and place these values in that content type.

Then in the portfolio, add a field called "Category" type Entity, and ensure it only shows the items of type "Category"

Your code will then get all Categories, a bit like this:
        // A source which can filter by Content-Type (EntityType)
        var allCategories = CreateSource<EntityTypeFilter>();
        allCategories.TypeName = "Category";
        @foreach (var cat in allCategories.List)
            // Here's the short version for the list of parent courses
            var courses = cat.Value.Relationships.AllParents    // all parents, no matter what entity-type
                .Where(c => c.Type.Name == "Course");           // now only the courses

            var category = AsDynamic(cat.Value);
                    @foreach (var course in courses)
Apr 23, 2014 at 12:48 PM
I tried this but got the following error

do i need to import or refenrence somethign in top of tempalte ?

There was an error while rendering the template: System.Web.HttpCompileException (0x80004005): d:\DNN7\sexytest\Website\Portals\0\2sxc\Content_portfoliotest.cshtml(6): error CS0246: The type or namespace name 'EntityTypeFilter' could not be found (are you missing a using directive or an assembly reference?)
Apr 23, 2014 at 1:04 PM
Sorry the example is very new - i'm just creating Apps :) - you need the newest 2SexyContent (the one from GitHub)

give me a about half an hour - i'll see that I can give you a functioning App :)
Apr 23, 2014 at 1:12 PM
ah that explains it.

So there is no option to do this in 5.5 yet as the type entity option was in the ui allready
Apr 23, 2014 at 1:16 PM
It actually already works, but the syntax is much more complex, so we are simplifying it a lot in 6.0
Apr 23, 2014 at 1:17 PM
when do you expect 6.0 to be released as non beta?
Apr 23, 2014 at 1:49 PM
within 1-2 weeks. We just need to make sure some apps exist, so people can discover the functionality.

I already created a GTM App and we're creating a bunch more

App catalog will be here (i'm working at it right now): upcoming App catalog
Apr 23, 2014 at 2:23 PM

That is right on time with my new skins so it will just be an extra update after the initial skin is done with the special app templates
Apr 23, 2014 at 3:04 PM
fyi: just published another demo-app showing various data-access mechanisms.