Lets say I have a component using a set schema, and this component is used with two opposing component templates, for example:
Component: Product A
Template One: Product Marketing
Template Two: Product Support
Through dynamic component linking, I want to be able to use the component's tcm uri to specify a hyperlink to where the content resides (using a dreamweaver template i.e. <a href="tcm:11-xxxx">Link text</a>
)
The problem is though that if links are being generated to the wrong parts of the website I'm working on, i.e. links to product support in the product marketing section and vice versa.
I've tried setting the linking priority of the templates...both set to high....but Tridion seems to use the last template that was published for deciding where links should go.
Plus if I set one of the templates to medium and the other to high, it just takes the links to the content using the template with highest priority (i.e. all links going to product support, even in the product marketing section)
Does anyone know how to solve this? Thanks!
Note Although it's possible for a component to render multiple templates, we recommend using an if:true|false directive to render nested templates conditionally instead. Create multiple HTML files in the component bundle.
In Angular 13 the new API removes the need for ComponentFactoryResolver being injected into the constructor, like you did in your code. Now to dynamically create a component you have to use ViewContainerRef.
if you want to insert HTML elements or other components in a component, then you do that using the concept of content projection. In Angular, you achieve content projection using < ng-content >< /ng-content >. You can make reusable components and scalable applications by properly using content projection.
In addition to Chris comments, You can use the tridion:excludetemplateuri attribute to exactly control which Component Template you can link to depending on the your need either marketing or support.
in DWT.. you could use something like this.
<a tridion:href="tcm:8-299" tridion:excludetemplateuri="tcm:8-420-32">linkText</a>
Here is the link for reference
Your issue is related to the context of the published Component Presentation. SDL Tridion resolves priorities for target CP as follows (where it only moves to the next step if there is more than one match):
This is normally due to you having either a Dynamic Component Presentation (DCP) which is not actually on a page, or for some reason the Page ID is not set in your linking code, so then it can't calculate the location of the current CP, and as such must skip step (2) from above.
That probably does not help you solve your problem, but it does explain what you are seeing. So I can be of more help, please explain what you are publishing (is it a DCP?), and possibly look at the published code and check if a Page URI has been added to the linking code (and make sure it is not tcm:0-0-0).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With