Search code examples
razordotnetnuke2sxc

How can I use presentation settings on a details view of a 2sxc app?


I have a 2sxc app that has a listing a details view. So I have two templates: _listing.cshtml and _details.cshtml.

My Details template uses the "Name in URL path" field like this: resource/.* so it filters individual items when the user browses to its URL.

On the listing settings, I can configure Presentation Settings for the listing and they show up when I go to edit the item in the list. But when I configure Presentation Settings on the details template, they don't appear in the edit modal.

How can I get Presentation Settings to work for the details view of the item in my app? (I know I could just make the fields as normal content fields in the content type but that seems like a hacky workaround... but I'll do it if I have to)


Solution

  • This can be done, but you must wire it correctly.

    Often the details view just uses a Query to get items with an ID. In this case though, you want to get the item from the current List / Module with the ID. Because only in the context of the list does the item have a Presentation property.

    So use the CmsBlock DataSource (in v12) or the ModuleDataSource (in versions before) to get the data of the current module, then filter the output of that by ID.

    A simple way to start is just to create a new query - that will show you the initial setup to just get the data for the current list/module.