EdwardChan
Crownpeak Employee
Crownpeak Employee

Quirks with copy.aspx and project branching

Within any template, you are able to add a copy.aspx file which would execute when an asset is copied, cloned or branched. Some general use cases for having a copy.aspx file in your template may be to clear out content fields or assign different values to content fields during a "copy" event. However, at the time of this writing, there are some known quirks with using the copy.aspx file when Project Branching is involved.

Let's say you have 2 project branches:

Project A
Project B

In each of these project branches there exists a "Copy Test" template, each having its own copy.aspx template file.

As an example, the code within each file is as follows:

/Project A/Templates/Copy Test/copy.aspx

<%
asset.SaveContentField("test_field", "Project A");
%>


/Project B/Templates/Copy Test/copy.aspx


<%
asset.SaveContentField("test_field", "Project B");
%>

All this code does is save the string "Project A" or "Project B" to a field called "test_field" when the asset is copied, cloned or branched.

Let's say you create two separate assets. One asset is assigned to the Copy Test template from Project A and the other is assigned to the one in Project B. When you copy, clone or branch these assets, which copy.aspx file would execute?

 

Scenario 1: Your Site Root does not have any project branches set per publishing state nor does it have a default set.

site-root-properties.PNG

In this case, regardless of the "Project" chosen:

site-root-project.PNG

The CMS will always fallback to the copy.aspx in the original branch.

 

Scenario 2: Your Site Root does have project branches set per publishing state but no default set.

site-root-properties-no-default.PNG

In this case, the copy.aspx file that would execute is the same as scenario 1 (eg. the CMS will always fall back to the original branch). Even if your asset was in a different state (eg. Stage or Live) when you initiated the copy, clone or branch, it will still fall back to the copy.aspx from the original project branch. The reason for this is because the copy.aspx executes after the copy has been created and as such the asset would be in the Draft state and would not match any of states set in the site root.

 

Scenario 3: Your Site Root has project branches set as well as a default.

site-root-properties-with-default.PNG

In this case, the copy.aspx file in the Default project is always used. As mentioned in scenario 2, the copy.aspx file executes after the asset has been copied and has been reset to the Draft state. Since we have a Default set in this case, it would cover the Draft state and the copy.aspx file from the selected Default project would execute.


So in conclusion, the only setting that really changes which copy.aspx file is executed is the Default dropdown from within your Site Root properties. Otherwise, the CMS will fallback to the copy.aspx file in the original branch. This is regardless of the template set on the assets themselves or the projects set for the different publishing states (eg. Dev, Stage, Live, etc.. ) of the site root.

Labels (1)

Can't find what you are looking for?

Find Answers

Search our DXM Forum to find answers to questions asked by other DXM users.

Ask a Question

No luck? Ask a question. Our Product and Support teams are monitoring the Forum and typically respond within 48 hours.

Ask a Question