0

Goal: load 2sxc content-blocks on demand in a single page application. If we could get the data that powers the content blocks, rather than markup, that'd be fine too.

Here's the first naive go at responding with markup from a webapi endpoint:

[HttpGet]
[DnnModuleAuthorize(AccessLevel = SecurityAccessLevel.Anonymous)]
[ValidateAntiForgeryToken]
public dynamic CityDetails(string id)
{
    return from city in AsDynamic(App.Data["City"]) 
        where city.Name == id
        select new {
            Name = city.Name,
            Details = city.Details.Aggregate("", (markup, contentBlock) =>
                markup += contentBlock.Render())
        };
}

Pointers would be appreciated!

EzraM
  • 139
  • 6
  • 'Can you provide some more details? Is the content-block you're addressing part of the same app & portal, or not? How many streams do you expect the content-block to have - just the basic "Default" or could it have many streams?' @iJungleBoy – kenorb Nov 10 '16 at 14:43
  • I worked around by not using content blocks but, the blocks were in the same app/portal, with one custom stream with the required data. Content blocks would have been more elegant. – EzraM Nov 11 '16 at 18:13
  • Great. If it worked, could you please answer your own question explaining the solution? – kenorb Nov 11 '16 at 18:17

1 Answers1

0

This is not an answer to the question but the workaround we used.

We made a content type with this structure:

  • Profile
  • Profile details entity A
  • Profile details entity B

We made two API endpoints:

  • Get profile overviews
  • Get profile details

Endpoints served a mix of data and markup from the WYSIWYG, which fed client-side templates.

In version 2, for SEO reasons, we'll structure the app more similar to the 2sxc Blog app. It'll be more difficult to do some of the animations, but seems a conservative lean toward server rendering is a good idea at this time.

EzraM
  • 139
  • 6