TinyButStrong - the PHP Template Engine
Categories > OpenTBS with ODT >

Setting hyperlink URL

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs

By: Kevin
Date: 2014-05-09
Time: 12:24

Setting hyperlink URL

Hi all,

thanks for TBS and the odt Plugin, works great :)

Thanks to the manual and forum I could work around almost all problems, but one is still left and I can't find a solution for it:

I'd like to set a dynamic hyperlink, but the URL will not get replaced... I am using replacer for both text and URL.
In my template I am marking a replacer as hyperlink and add the URL replacer in the dialog "Insert>Hyperlink>Internet>Web>Target" like this: [var.~myUrl] where [var.~myUrl] contains "http://www.example.com".

After using TBS on my template and saving the output the hyperlink text got replaced correctly, but the HREF got corrupted: file:///myTargetDirectory/templates/%5Bvar.~myUrl%5D

Something seems to encode the square brackets [] with %5B and %5D.

The problem occurs no matter if I use a static text or a replacer as URL text.

Using the debug plugin, I can see that the problem might be within LibreOffice itself, saving the URL already wrong:
[
    <text:a xlink:type="simple" xlink:href="file:///myTargetDirectory/templates/%5Bvar.~myUrl%5D">
     myTargetDirectory
    </text:a>
    ]

I am curious if anyone ever had a similar problem and knows how to fix it?

Thanks in advance
Kevin

EDIT:

What I found out so far:

1) When I close my template and reopen it, the URL is already wrong, so the problem does not lie in TBS or the ODT plugin!

2) When I change the chr_open and chr_close to '*' the URL gets replaced correctly, BUT: I'd have to change my complete template, repalcing all brackets with * and what is worse: OO will still display it as document, because the http:// was missing when I saved the template (not the generated document). So OO assumes that I am pointing to a relative path. The generated URL looks like this: file:///myTargetDirectory/templates/http://www.example.com after conversion.
By: Vincent
Date: 2015-04-08
Time: 18:44

Re: Setting hyperlink URL

Hey,

I have been putting off implementing a new feature to my app, hoping to see a new feature added to OpenTBS to do exactly this: adding a hyperlink to a document. Any news on this? Did you succeed to workaround the problem?

Thx,
Vincent
By: Vincent
Date: 2015-04-30
Time: 11:50

Re: Setting hyperlink URL

Maybe I can trigger some thoughts by replying some findings to myself...

In an .odt-file, a hyperlink supposedly is saved as:
<text:a xlink:href="[URL]" xlink:type="simple">[NAME]</text:a>

Would it then not be possible to:
1. Merge both [URL] and [NAME] in the template, f.e. like this (([URL])([NAME]))
2. Open the content.xml-file
3. Find and replace the (([URL])([NAME])) with <text:a xlink:href="[URL]" xlink:type="simple">[NAME]</text:a>
4. Save the content.xml-file
?

I presume that if it were simple, other people would have thought of this solution (and posted it to this forum) - but, before I spend a complete weekend on this, it doesn't hurt to ask if this is feasible at all without any annoying side-effects...

Anyone?

Thx,
Vincent