Component link using Tridion custom tags
i.
Modify
web.xml to make a reference to cd_tags.tld
ii.
Copy
cd_tags.tdl to WEB-INF/lib
iii.
Create
JSP file link1.jsp
iv.
Add
tag declaration in the top of file: <%@ taglib uri="cd_tags" prefix="tridion"
%>
v.
Add
page content type declaration: <%@ page contentType="text/html; charset=UTF8" %>
vi.
Generated
code:
<tridion:ComponentLink pageURI="tcm:83-3241-64" componentURI="tcm:83-3236" templateURI="tcm:0-0-0" addAnchor="false" linkText="click me" linkAttributes=" title="Component 2" " textOnFail="true"/>
<tridion:ComponentLink pageURI="tcm:83-3241-64" componentURI="tcm:83-3236" templateURI="tcm:0-0-0" addAnchor="false" linkText="click me" linkAttributes=" title="Component 2" " textOnFail="true"/>
Component link using Java objects
ComponentLink
compLink = new ComponentLink(83);
String linkAsString =
compLink.getLinkAsString(3241, 3236, 0, "", "Click
Me", true);
out.write("The
link: " + linkAsString + "<br />");
Link link =
compLink.getLink(3236);
if
(link.isResolved()) {
out.write("Link
resolved: " + link.getURL());
} else {
out.write("Link NOT
resolved");
}
Comments