Pages: 1
Print
Author Topic: Preventing insertion of <linktext> in related links  (Read 3578 times)
Scibert
Member

Posts: 25


« on: August 16, 2012, 11:43:49 AM »

In XMetaL 7, when you add a related link by clicking Insert > Link > Related Link To Topic, the link is automatically wrapped with a <linktext> element. Is there a way to prevent this behavior?

For example, I want this code to be inserted...

<link href="topic.dita" format="dita" scope="local"><?xm-replace_text Element: Topic?></link>

...instead of...

<link href="topic.dita" format="dita" scope="local"><linktext><?xm-replace_text Element: Topic?></linktext></link>
« Last Edit: September 04, 2012, 01:23:33 PM by Scibert » Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 2621



WWW
« Reply #1 on: August 16, 2012, 04:19:11 PM »

This can be done but you must be careful.

1. Open the corresponding CTM file for the topic type you wish to change this for in a text editor (like Notepad).

Examples:

"topic" DTD for DITA 1.2
C:\Program Files\XMetaL 7.0\Author\DITA\XACs\1.2\topic\topic_ditabase.ctm

"concept" DTD for DITA 1.1
C:\Program Files\XMetaL 7.0\Author\DITA\XACs\1.1\concept\concept_ditabase.ctm

2. Locate the following section:
    <Template>
      <Name ns="">link</Name>
      <MiniTemplate><![CDATA[<link><linktext><?xm-replace_text Link?></linktext></link>]]></MiniTemplate>
    </Template>


3. Change to:
    <Template>
      <Name ns="">link</Name>
      <MiniTemplate><![CDATA[<link></link>]]></MiniTemplate>
    </Template>


4. Save the CTM file.
5. Repeat as necessary for each DITA document type you need to alter.

If you mess this up somehow then reinstalling the software should restore any CTM files you have broken.

Note: This may not work for every "template" due to the way the DITA functionality has been scripted. In most cases the code that inserts elements uses the template in the CTM file (by calling the API "InsertWithTemplate") but in some cases it does not. It just happens that for <link> it does.

Officially this type of change is not supported, even though it should work in this case. What "unsupported" means here is that if an end user contacts saying that the <linktext> is not being inserted (without letting anyone know CTM changes were made, which is very likely) we won't be able to reproduce the issue. XMetaL Support (if that channel is used) would end up having the end user reinstall the software to put it into a standard state, at which point the issue would go away, but any customizations would disappear as well. So, if you make these types of changes make sure your end users contact you for help.
Logged
Scibert
Member

Posts: 25


« Reply #2 on: August 16, 2012, 05:53:51 PM »

Hi Derek,

This solution works. Thanks!
Logged
scorho
Member

Posts: 17


« Reply #3 on: August 30, 2012, 10:33:42 AM »

I suspect that the OP wants to do this due to an issue we're seeing as well. In XM6, the <linktext> tag was not inserted, and related links worked fine. In xm7, the <linktext> tag actually makes it so link text is NOT generated.



results in:



The link is actually created in the html output, but the link text appears as empty white space in the html code, so it does not actually display at all. Remove that <linktext> tag and everything works as expected.
Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 2621



WWW
« Reply #4 on: August 30, 2012, 06:07:00 PM »

I see. I'll check with dev to see if they were thinking something else when they made this change and recommend they revert it.
Logged
Scibert
Member

Posts: 25


« Reply #5 on: September 04, 2012, 01:20:44 PM »

After changing the code to ...  
 
<Template>
      <Name ns="">link</Name>
      <MiniTemplate><![CDATA[<link><?xm-replace_text Link?></link>]]></MiniTemplate>
</Template>


... the link's topic name no longer appears in the authoring interface -- the string "Link" is always displayed instead.

How can this be fixed?


* link.png (1.94 KB, 261x50 - viewed 493 times.)
« Last Edit: September 04, 2012, 01:25:27 PM by Scibert » Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 2621



WWW
« Reply #6 on: September 05, 2012, 02:31:15 PM »

Don't include the PI you are including in the mini-template and things should be OK. See the change I made in my previous post.

Note that in XMetaL Author Enterprise 7.0 you can control how references and other things are updated when "refreshing references" (F11) at a much finer level than with 6.0. These settings are in Tools > DITA Options > Update Content (tab). There is a section on the right labelled "Reference types". The setting that controls this particular type of reference is the checkbox labelled "xref/related-links".
Logged
Pages: 1
Print
Jump to:  

email us