One of my last post discussed about the Tridion Custom Web Controls. To end with, let’s explore one more such Custom Web Control: PageLink.
PageLink Control ,as guessed by it’s name, is used to create a link to other page within the Content Manager. I believe, this is the simplest to use and if you have followed my last post , I guess, even just knowing the names of the public properties of this Control Class, you can predict there use.
The most powerful feature of this control is to append Query Strings and Anchor sections to the URL, thereby allowing server side processings, as for what Query strings are used most of the time.
The Content Manager URI of the destination page to which the link needs to be created. Note that the PageURI must be of the same Publication.
This is the Query string to be appended at the end of URL. Note that the string should be in a format something as: “category=general&type=article&subtype=lifestyle” , as in:
<tridion:PageLink Parameters="category=general&type=article&subtype=lifestyle" .... />
so the resultant HTML <a> tag will look like:
<a href="http://www.lifestyle.com/lifestyleproducts.aspx?category=general&type=article&subtype=lifestyle" .... />
This attribute basically determines creation of HTML Anchor Link ( Anchor Sections on a Webpage )
Set this to the ID of any anchor section to be linked to. For example, if the destination page has a section with <a href=”#lifestyleSection” >Our Latest Products on Lifestyle</a>, the Anchor attribute should be set to:
<tridion:PageLink Anchor="lifestyleSection" .... />
The end result will be something similar to:
Any attributes we need to set for the <a></a> tag such as for example: class=”lifestyleSection” , as in :
<a class=”lifestyleSection” target=”_blank” href=”…”>ViewMore</a>
Such attributes will be placed inside the LinkAttributes and the TCDL tag should be:
<tridion:PageLink LinkAttributes=" class=" ;lifestyleSection" ; " ... />
This is the standard text to be displayed for the Link.
Set this to a boolean value true / false. In case the Dynamic Link Resolver fails to resolve the link to destination page ( such as Page is NOT published / Present on Presentation server), the value of this attribute determines what to do next.
true: Show the plain text without a hyperlink even if link resolving fails.
false: Removes the link text in case link resolving fails.
The default value for this attribute is true.
So, once the above TCDL tag is resolved at runtime, the resultant standard HTML tag generated will be:
<a href="http://www.lifestyle.com/lifestyleproducts.aspx?category=general&type=article&subtype=lifestyle#lifestyleSection" class="lifestyleSection" target="_blank"> ViewMore</a>
Note that the anchor section (# part) is placed at the end of URL.
As an end note, keep in mind that the markup of these Custom Web Controls are indeed the TCDL tags generated by the Link Resolver TBB as a part of the publishing process.
Hope you enjoyed the posts discussing basics of Tridion Custom WebControls. Comments and Suggestions are welcome.
Any questions should be redirected to Tridion Q & A website: http://tridion.stackexchange.com