0

I'm working on an umbraco project which has a lot of duplicate documents. I need multiple documents in my navigation structure which have the same content but a different title and a different position in the navigation tree. I created a documenttype with the generic property "copypage" (Type ContentPicker) where the editor can set which page's content should be mirrored. My current solution for this looks like

var page = Library.NodeById(Model.copypage);
@page.contents;

but this leads to problems with macros contained in the mirrored page.

Edit: My problem is that the macros on the original document access the documents children. Those children are not copied as children to the mirrored page. So my target is to execute @Html.Raw(umbraco.library.RenderMacroContent(page.contents.ToString(), Model.Id)) in the context of the original page.

Georg Jung
  • 949
  • 10
  • 27

2 Answers2

1

The most tested solution for rendering content from another page is the uComponents macro "RenderTemplate". i

You can build your templates with Razor, or whatever it is that you like, then use the ID of the page to render it in another template. This is often used to render a number of widgets on another page. All you need is the ID of the page to be rendered. The macro also supports rendering with a different template.

<umbraco:Macro runat="server" Alias="RenderTemplate" NodeIds="1,11,12" CurrentPage="1" EntriesPerPage="10" AltTemplateId="0" UseChildNodes="0" />

Another solution would be to use the umbraco property "umbracoInternalRedirectId". This property redirects to another page, but keeps the URL of the initial request, masking the url for the other page.

Astuanax
  • 667
  • 5
  • 18
  • I have ssen the option to copy a document. The dialog asks to "relate" those documents. This sound like the feature I am looking for but it does not work like I expected. What does relating do? What are relation types in the developers section? – Georg Jung May 30 '14 at 15:19
  • 1
    The relate creates a row in the relationship table, but what that relations ship does is up to you. In version 6 there is a default action to copy the content, duplicating the whole page in another location. – Astuanax May 31 '14 at 10:43
  • I'm afraid I can not use `RenderTemplate` or `umbracoInternalRedirectId`, because it mirrors the complete page including navigation, menus etc. – Georg Jung Jun 03 '14 at 13:07
0

I found an answer to my specific question myself. Changing every of my custom macros like the following solved my problem.

var widgetsFolder = Model.WidgetsFolders.First();
if (Model.HasValue("copypage")){
  var page = Library.NodeById(Model.copypage);
  widgetsFolder = page.WidgetsFolders.First();
}
Georg Jung
  • 949
  • 10
  • 27