3

I have a problem with the Dynamic Linking functionality.

I have a Component Template which renders the rest of the Components of the Page, so when I try to find a Component of this Page in the LINK_INFO table I don't see it because it has been rendered from the Component Template, not the Page Template, I think. I mean, I have a Page with a Component Template which execute the RenderComponentPresentation method of the rest of the Component Presentations in the Page, like that:

<!-- TemplateBeginRepeat name="AuxiliarComponents" -->
    @@RenderComponentPresentation(Component.ID, ComponentTemplate.ID)@@                  
<!-- TemplateEndRepeat -->

I have tried this pieces of code too:

<!-- TemplateBeginRepeat name="AuxiliarComponents" -->
    @@RenderComponentPresentation()@@                  
<!-- TemplateEndRepeat -->

<!-- TemplateBeginRepeat name="AuxiliarComponents" -->
    ${RenderComponentPresentation()}                  
<!-- TemplateEndRepeat -->

This codes renders and publish the content of the AuxiliarComponents well, but they are not in the LINK_INFO table, so I can't use dynamic linking functionality.

Is it possible to include it in this table rendering from the Component Template? Is there any option to include it in this table through Component or Page Template?

All the Component are in the Page added like normal Component Presentations, but the most of them are rendered by some Component Templates. Is there any way to do that from this Component Templates? Is there another problem?

Is it possible to execute in the Component Template something like that to solve it?

<tcdl:ComponentPresentation type="Embebbed" pageURI="tcm:786-228287-64" componentURI="tcm:786-228076" templateURI="tcm:786-227832-32" xmlns:tcdl="http://www.tridion.com/ContentDelivery/5.3/TCDL" />

If the problem is the render context, I have added this code in a TBB, called from CT before render the Component Presentations, to add the Page to the package:

if (engine.PublishingContext.RenderContext.ContextItem != null)
{
    Item pageItem = package.CreateTridionItem(ContentType.Page, engine.PublishingContext.RenderContext.ContextItem.Id);
    package.PushItem("Page", pageItem);
    sesion.ContextData.Add("Page", pageItem);
    engine.PublishingContext.RenderContext.ContextVariables.Add("Page", pageItem);
}

With this code I can get the TCM URI of the Page in my DWT code with this:

<h1>@@Page.ID@@</h1>

Thanks in advance.

5
  • Are the components in the page? If they’re not and they’re “pulled in” from the component template, then indeed linking won’t work.
    – Nuno Linhares
    Commented Dec 19, 2017 at 20:34
  • Your question is not clear to me, can you edit it and provide some more detail on what you mean with that a "Component Template, renders the rest of the Components on the Page"? Maybe try to explain it by some steps we can use to reproduce the problem, or include some code snippets of what rendering you exactly mean etc. Commented Dec 20, 2017 at 8:33
  • I have edit my question with more information. Commented Dec 20, 2017 at 8:56
  • @NunoLinhares, Yes, all the Component are in the Page added like normal Component Presentations, but the most of them are rendered by some Component Templates. Is there any way to do that from this Component Templates and indexing them into the LINK_INFO table? I have added more information to the question to help to you understand better the problem and what I have tested. Commented Dec 20, 2017 at 16:48
  • I'm still missing the reasoning from you not to render all CPs on the Page in the Page Template. If you would do that, you won't have any issue and the link info will be available. I'm afraid what you are now trying to do is symptom solving which won't deal the actual problem. I don't see a solution to your problem without moving rendering all CPs to the Page Template (and you didn't get any other answers helping you there yet). Commented Dec 21, 2017 at 10:48

1 Answer 1

3

Linking information is added based on the Component Presentations on the Page, and in your case that is done by the RenderComponentPresentation() calls you make in the Page Template.

You mention you delegated rendering of some of your Component Presentations to a Component Template, by calling RenderComponentPresentation(Component.ID, ComponentTemplate.ID) in there. I think that is indeed the root of your problem why the additional Component Presentations are not added in the LINK_INFO table for that Page (since the system doesn't know they are actually rendered on the Page).

I think you need to wonder why you have chosen for this approach of not having all Component Presentations rendered in the actual Page Template. You mention the Components are on the Page, so then let the Page be responsible of rendering them. I don't see many other solutions, since the Component Template doesn't know in what context it is rendered, so it can't really behave different when on a Page or not.

3
  • And is it not possible to create a TBB to put the page into the context and in this way the Component Template should know in what context it is rendered? Commented Dec 20, 2017 at 11:17
  • @SergioAlonso no, to my knowledge this context was available in VBScript Templating but has been removed in Modular Templating as it was considered incorrect practice (and probably some other technical reasons ;o). So I'm afraid you really need to look at the reasoning behind you wanting to render Component Presentations outside of the Page Template (perhaps edit your question and provide detail on that, so it can be considered in an answer). Commented Dec 20, 2017 at 11:21
  • I have edit my question to add more information talking about <tcdl:ComponentPresentation> Commented Dec 20, 2017 at 17:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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