6

I have a scenario where there are several websites powered by Tridion and there are component links that I want to resolve across web publications.

For example: There is a Corporate site: publication ID 14, and a niche site: Publication ID 13.

The Corporate site has an "About Us" page with an "About Us" article component, and the niche site has a component link to the "About Us" article.

My cd_link_conf.xml has the following:

  <Publication Id="13">
    <Host Domain="mynichesite.com" Port="80" Path="/"/>
  </Publication>  
  <Publication Id="14">
    <Host Domain="mycorporatesite.com" Port="80" Path="/"/>
  </Publication> 

Everything is published into the same broker DB, so the LINK_INFO table contains everything. However, when browsing in the niche site (pub 13) the dynamic link to the About Us article on the About Us page in pub 14 is not resolved. Am I missing some configration, or do I need to have logic to get the "pub 13" TCM URI of the About US component before I try to resolve the link?

---- UPDATE ----

I am now considering writing the following algorithm to get my links working. Since we're using DD4T, I'm planning to extend the IComponent.ResolveUrl() method with the following:

  1. get component link TCM URI
  2. try resolve in current pub. If resolve, then return, else...
  3. try another pub by localizing the TcmUri to the next pub (need to keep/get the list of pubs somewhere)
  4. try resolve in next pub. If resolve, then return else...
  5. repeat step 3 until out of pubs to scan or a link is found.

Still not ideal, but if you've done something like this before, please share.

1
  • So I just tried using the TCM URI and it worked. Basically, in pub 14 change the publication prefix of the tcm uri to pub 13 and then call link resolving. It returns the proper page URL. However, this is going to require a bit of logic for checking all the links - not ideal. May 10, 2013 at 14:43

1 Answer 1

5

Cross-publication linking has always worked - as far as I remember - as long as everything is correctly configured.

I used this in a language selector logic before:

  • Get Current Page ID ("tcm:13-123-64")
  • Get target publication Id ("14") which I have as part of my selector's source xml
  • Get link to Page with ID "tcm:13-123-64" in context of Publication 14

So, you seem to be almost there. You do need to create a Link object bound to the publication where you want to find the item.

Be aware that this code will work cross publication:

ComponentLink componentLink = new ComponentLink(14); // 14 is corporate
Link link = componentLink.GetLink("tcm:13-123"); // 13 is niche
link.Url; // returns http://mycorporatesite.com/path/to/page

This would resolve the link to "tcm:13-123" but in context of publication 14 (the one used to initialize the ComponentLink object), so you don't really have to bother localizing the URIs.

2
  • Thanks Nuno. My "localizing" I meant getting the ID in the context publication. I guess my issue is that a page to the link can exist in any pub, so I don't have the context publication like in a language switcher. May 10, 2013 at 16:13
  • Answer removed! I didn't know you could do this :) May 10, 2013 at 16:16

Your Answer

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

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