作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我一直在尝试使链接在 openTBS 生成的文档中起作用。
到目前为止没有运气:(
<?
include_once('tbs/tbs_class.php');
include_once('tbs/plugins/tbs_plugin_opentbs_1.8.1/tbs_plugin_opentbs.php');
$TBS = new clsTinyButStrong('!-,-!');
//the special pattern is needed because
//word replaces [] brackets when put in link's href.
$TBS -> Plugin(TBS_INSTALL, OPENTBS_PLUGIN);
//some variables for mergeing with the template
$tmpl_headname='Sarah';
$tmpl_headlink='http://example.com/?user=sarah';
$tmpl_items = array(
array('title'=>'My title', 'url'=>'http://myurl.com/firstarticle'),
array('title'=>'My second title', 'url'=>'http://myurl.com/secondarticle'),
array('title'=>'My third title', 'url'=>'http://myurl.com/thirdarticle')
);
$TBS->LoadTemplate('sampledoc.docx');
$TBS->MergeBlock('item',$tmpl_items);
$TBS->Show(OPENTBS_DOWNLOAD, 'sample_filename_doc');
?>
This is your unique link, !-onload.tmpl_headname-! (points to: !- onload.tmpl_headlink-!)
!-item;block=begin;tbs:page-!
!-item.title-!
Link to the website (points to: !-item.url-!)
***
!-item;block=end;tbs:page-!
!-item.url-!
,并且在其上运行 openTBS 后它保持不变。问题是,在 Docx zip 文件中,在
word/_rels/document.xml.rels˙
,它们看起来没有变化:
<Relationship TargetMode="External" Target="!-item.url-!" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink" Id="rId8"/>
$TBS->LoadTemplate('tbs/sampledoc.docx#word/_rels/document.xml.rels');
rId
生成 ID前缀:
rId1
,
rId2
等。资源文件中的所有其他项目都与
rId[x]
链接。图案。
***
My second title
Link to the website
<w:p w:rsidRDefault="00886D12" w:rsidP="00886D12">
<w:r>
<w:t xml:space="preserve">
***
</w:t>
</w:r>
<w:r>
<w:br/>
</w:r>
<w:r>
<w:t>
My second title
</w:t>
</w:r>
<w:r>
<w:br/>
</w:r>
<w:hyperlink r:id="rId7" w:history="1">
<w:r>
<w:rPr>
<w:rStyle w:val="Hyperlink"/>
</w:rPr>
<w:t xml:space="preserve">
Link to the website
</w:t>
</w:r>
</w:hyperlink>
</w:p>
...
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
<Relationship Id="rId8" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable" Target="fontTable.xml"/>
<Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings" Target="settings.xml"/>
<Relationship Id="rId7" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink" Target="!-item.url-!" TargetMode="External"/>
<Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/>
<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml" Target="../customXml/item1.xml"/>
<Relationship Id="rId6" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/endnotes" Target="endnotes.xml"/>
<Relationship Id="rId5" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes" Target="footnotes.xml"/>
<Relationship Id="rId4" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings" Target="webSettings.xml"/>
<Relationship Id="rId9" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme" Target="theme/theme1.xml"/>
</Relationships>
最佳答案
这太难在评论中显示了。
您可能需要使用 att
参数:http://www.tinybutstrong.com/manual.php#html_field_prm
类似的东西(未经测试):
<Relationship TargetMode="External" Target="" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink" Id="rId8">
!-block=item;att=Target;item.url-!
</Relationship>
att=Relationship#Target
而不是像我一样打开关系标签。像这样的东西(真的未经测试):
<Relationship TargetMode="External" Target="" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink" Id="rId8"/>
!-block=item;att=Relationship#Target;item.url-!
rId
提供一个唯一的 ID。属性,很明显。您可能希望在此处遵循 OpenTBS 的示例并使用与 Word 不同的结构以避免冲突。类似
rId=mytbs1
而不仅仅是
rId=1
(OpenTBS 使用
opentbs1
作为图片,但您也不想在那里发生冲突)。
$items = array(
array('title' => 'My Title1', 'url' => 'http://my.url', 'rId' => 'myTBS1'),
array('title' => 'My Title2', 'url' => 'http://my.url', 'rId' => 'myTBS2'),
);
!-item;block=begin;tbs:page-!
!-item.title-!
Link to the website
***
!-item;block=end;tbs:page-!
!-block=item;item.url-!!-item.rId;att=rId-!
rels
模板:
<Relationship TargetMode="External" Target="" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink" Id="rId8">
!-block=item;att=Target;item.url-!
!-item.rId;att=rId-!
</Relationship>
关于docx - 合并/修改 openTBS 中的超链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19637390/
我是一名优秀的程序员,十分优秀!