8

Is there a way to resolve a component link based on a tcm without it beign between src="" or href="" ?

I mean, I have the TCM and I need to put the link in between a because is a RSS Feed but I don't know how to do that.

I know that if it were a .cs file I would do something like:

ComponentLink link = new ComponentLink(publication);
link.GetLink(tcm).Url;

But I don't know how to do it directly in a Razor TBB without needing an extra code fragment.

Kindest regards!

2
  • It's not clear from your question what you are trying to achieve. Are you trying to generate ComponentLink code to run on the content delivery side? Commented Mar 19, 2013 at 12:24
  • I'm creating a RSS feed and I have to put the url of each component between <link></link>. I know that if I do <a href="@Component">blah</a> it will be resolved but what I want to do is something like <link>@Componet</link> and get the URL there to have <link>whatever</link>
    – Wallack
    Commented Mar 19, 2013 at 12:42

2 Answers 2

8

What you're trying to achieve is not as trivial as you think. Component Linking is a Content Delivery feature and it takes into account a lot of variables, such as "is this component published", "which component template has the highest priority" and if the component is published in multiple pages with the same template priority, "which target page is closest to the current one".

Since you want to resolve this URL at publish time to create a static feed, you cannot use Dynamic Linking for this. A few solutions:

  • Make your RSS feed an executable page (rss.aspx or rss.jsp) or execute it via a Filter or Http Module. This would allow you to use dynamic linking
  • "Resolve" the Url at publish time by:
    • Using "where used" to find pages containing the component
    • Determine which pages are actually published so that you don't publish a dead link
    • If the component is in multiple published pages, determine which one uses a template with the highest priority

Link resolving is not trivial, as you can see from the above description. A more thorough description is available in the SDL Tridion LiveContent (login required).

3
  • Good point, deleted my answer. Commented Mar 19, 2013 at 12:34
  • I was just thinking if is there a simple way as there is with <a href="@Component">blah blah</a> to solve directly the link. I mean if there is so simple with the href or the src should be good to have another option to solve the link.
    – Wallack
    Commented Mar 19, 2013 at 12:44
  • Yes - That link is resolved on the delivery side, not on publishing.
    – Nuno Linhares
    Commented Mar 19, 2013 at 15:07
4

You should use Tridion dynamic linking on the content delivery side. Simply template your RSS page using standard techniques, using a component link for each of the links in the RSS page. Just because it's an RSS page doesn't make it special. From a technical viewpoint, it's just another page.

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