简体   繁体   中英

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)

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.

I am answering without trying this or testing, so hopefully someone like Daniel will chime in with a better way, but I think the problem is context. I am assuming you edit from the List View? Showing an Edit blue-circle-pencil via TabToolbar? When you edit the item on the list view, the Presentation entity is in the context of that module and List view.

So when you display in Detail View, the Presentation item is not there because you did not launch the Edit from there.

Have you tried NOT emitting the TagToolbar on the List View and only allowing Edit in Detail View? Or ALSO emit it on the Detail View and see if you get different settings?

If this works its pretty interesting. It would mean that for each content item, you could hook up a different Presentation content-type and you could have different Presentation settings for List vs Detail.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM