2sxc | Copy modules page template of more than one multiple for each instance

63 views Asked by At

I'm able to create a page template of modules and copy it to a new page fine.

Problem is that this template page consists of modules that close the view picker without editing/adding any data and as a result have only one single multiple of each module.

My aim is to create a template page of modules that have a row of three modules already placed on the template page but when I copy this it links the multiples with the original template (I presume it considers adding a multiple of three to a module is entering data which breaks the copy template procedure?).

Is there a work around that I can have a module always drop on as a multiple of 3 for a link list template?

Thx

1

There are 1 answers

0
iJungleBoy On BEST ANSWER

Basically your special wish is to create a more complex preview than the default preview provides. In this case the strategy is as follows:

  1. in your template, detect that you are showing the preview item
  2. show the optimized preview as you want it

How is this done? Basically the preview-item can be detected with high reliability either with the entityID, or the guid (if you want to guarantee that this functionality works after app-export/re-import).

The code is ca. like this

// detect the demo item, because we shouldn't add inner content while still showing this one
var isDemoItem = Content.EntityGuid.ToString() == "e90752f1-29d5-46a3-984c-408d97feae91"; // use your demo-item guid here
var fakeList = new List<DynamicEntity>();
fakeList.Add(Content);
fakeList.Add(Content);
fakeList.Add(Content);

@foreach (var Content in ( isDemoItem ? fakeList : AsDynamic(Data["Default"]) ))
{
    ...
}

Our content-accordeon app (not yet published, but visible in github) uses a similar strategy, to ensure that the demo-accordeon doesn't accidentally get content inside it in the preview-item

https://github.com/2sic/app-accordion-bootstrap3/blob/master/_Accordion.cshtml