2

I have a tabs module that uses dynamic placeholders in order to add existing modules under each tab. The tabs module has a datasource item that is a folder for tab items. I loop through each tab item and render a tab label for users to click on to switch between active tabs and a dynamic placeholder for each item.

I want a way to easily switch the position of tabs with an existing tab. I tried the default sort button for my tabs module but it only changed the position of the label of each tab. All the content added to a tab dynamic placeholder stayed in the order it was originally added rather than ordering with the tab label that was moved.

Will I need to remove dynamic placeholders and nest module items under each tab item or is there a different way to handle this? If I need to nest module items in the tree I think I'm going to use item renderings as my path to determine what to render for each item under a tab item. I am using Fortis's dynamic placeholder implementation.

5

The behaviour you're seeing is because, by default, an incremental integer is used to differentiate the same placeholder name/rendering ID.

The current version of Fortis Dynamic Placeholders allows you to override the default behaviour of the key generation (incremental integer). You can instead pass in your own unique key to differentiate the placeholder from others.

I assume your rendering currently has something like the following in it for each tab output:

@Html.Sitecore().DynamicPlaceholder("<placeholder>")

If you replace it with:

@Html.Sitecore().DynamicPlaceholder("<placeholder>", tabItemIdGuid.ToString())

Replace tabItemIdGuid with however you can get the ID in GUID form. Your placeholders will now "lock" to the tab item.

This does require version 1.2.0.0 of the MVC Dynamic Placeholders.

|improve this answer|||||
  • I'm not actually seeing that as an option since I'm on 1.1.0.1. I'll try upgrading and see how that works out. – Teeknow Nov 27 '17 at 18:37
  • It worked out. In the meantime I had ended up rolling out my own thing which didn't replace the appended key but instead I was replacing the rendering id with my item's id and things seemed to just work out due to pattern matching in the dll. I would have posted that if there wasn't an easy route like this available. Thanks! – Teeknow Nov 27 '17 at 19:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.