如何从Diazo规则文件中链接它们内部的URL? [英] How to link an URL inside the them from the Diazo rules file?

查看:71
本文介绍了如何从Diazo规则文件中链接它们内部的URL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果在HTML模板中设置了图像的URL,则该URL将更新为引用主题文件夹中的文件.例如,

If an URL to a image is set in a HTML template, then the URL is updated to reference files inside the theme folder. For example,

<img src="image.png" />

替换为:

<img src="http://localhost:8080/mysite/++theme++mytheme-theme/image.png" />

但是,如果我编写以下重氮规则:

However, if I write following Diazo rule:

<replace css:content="#some-class">
   <div id="#some-class"><img src="image.png" /></div>
</replace>

图像的URL未更新.如何编写正确引用图像的Diazo规则.我想使用<img src="path/image.png">在模板HTML文件中引用此图像.但是,不清楚放置什么而不是放置路径.我注意到该路径不能是绝对路径,因为它取决于站点域.另外,它不能是相对路径,因为它取决于站点中每个页面的路径.使用特定的关键字来引用主题文件夹可能会很有用.例如,<img src="$themeFolder/image.png">.存在这样的关键字吗?

the URL of the image is not update. How can I write Diazo rules where the image gets correctly referred. I want to refer this image in the template HTML file with <img src="path/image.png">. However it is not clear what to put instead of path. I notice that path cannot be an absolute path because it depends of the site domain. Also, it cannot be a relative path because it depends on the path of each page in the site. May be it would be useful to have an specific keyword to reference the theme folder. For example, <img src="$themeFolder/image.png">. Exists such keyword?

推荐答案

您可以在主题的manifest.cfg文件中创建XSLT参数.只需添加一个节,如:

You may create XSLT parameters in your theme's manifest.cfg file. Just add a stanza like:

[theme:parameters]
theme_base_url = string:${portal_state/portal_url}/++theme++mytheme-theme/

然后您可以在规则文件中使用它:

Then you may use it in your rules file:

<replace css:content="#some-class">
   <div id="#some-class">
     <img><xsl:attribute name="src"><xsl:value-of select='$theme_base_url' />image.png</xsl:attribute></img>
  </div>
</replace>

这篇关于如何从Diazo规则文件中链接它们内部的URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆