[opencms-dev] rendering external links with attribute target="_blank"
Wiesner, Daniel
daniel.wiesner at av-studio.de
Tue May 17 21:06:05 CEST 2005
I think the only possible solution is to modify the
org.opencms.staticexport.CmsLinkProcessor class. I added this to
processLinkTag(LinkTag linkTag)
if (linkTag.getAttribute("target") == null && !link.isInternal()){
linkTag.setAttribute("target","\"_blank\"");
}
Now all external links without a target attribute will be opened in a
new window.
Daniel
/**
* Process a link tag.<p>
*
* @param linkTag the tag to process
*/
protected void processLinkTag() {
switch (m_mode) {
case C_PROCESS_LINKS:
if (linkTag.getAttribute("href") != null) {
CmsLink link =
m_linkTable.getLink(getLinkName(linkTag.getLink()));
if (link != null) {
linkTag.setLink(processLink(link));
//if no targetwindow is assigned and the link is
external open a new window
if (linkTag.getAttribute("target") == null &&
!link.isInternal()){
linkTag.setAttribute("target","\"_blank\"");
}
}
}
break;
case C_REPLACE_LINKS:
if (linkTag.getAttribute("href") != null) {
String targetUri = linkTag.extractLink();
if (CmsStringUtil.isNotEmpty(targetUri)) {
String internalUri =
CmsLinkManager.getSitePath(m_cms, m_relativePath, targetUri);
if (internalUri != null) {
linkTag.setLink(replaceLink(m_linkTable.addLink(linkTag.getTagName(),
internalUri, true)));
} else {
linkTag.setLink(replaceLink(m_linkTable.addLink(linkTag.getTagName(),
targetUri, false)));
}
}
}
break;
default:
// noop
break;
}
}
Wiesner, Daniel schrieb:
>hello,
>
>is there any way to tell ocms 6.0 b3 to automatic render links with the
>atribute internal="false" to
>
><a target="_blank" href="... ?
>
>
>Users don't have a dialog for setting this in pages using the new
>xml-content feature. But if they paste text containing links - the target is
>not set at all and so the browser is using the default "_self".
>
>regards
>Daniel
>
>
>
>_______________________________________________
>This mail is send to you from the opencms-dev mailing list
>To change your list options, or to unsubscribe from the list, please visit
>http://mail.opencms.org/mailman/listinfo/opencms-dev
>
>
More information about the opencms-dev
mailing list