繁体   English   中英

如何在href中使用typo3常量?

[英]How to use a typo3 constant in an href?

为了tx_dti.settings.url = https:/someserver/ ,我可以在模板tx_dti.settings.url = https:/someserver/页面的主URL定义为常量: tx_dti.settings.url = https:/someserver/

现在,我想在文本元素中使用此常量来链接内部页面,例如:
<a href="{tx_dti.settings.url}?id=13" class="internal-link">Contact Form</a>

不幸的是,我上面提到的方法不起作用。
用常量替换服务器的正确语法是什么?
目的是当我从开发人员转移到生产服务器时,我只想更改常量。

一般来说:
您不能在拼写模板(常量和设置)之外使用拼写常量。 如果要在其他情况下使用印刷文字常量的值,则需要传输该值。

如果要在流体中使用常数,则需要将值转换为流体变量。

temp.content = FLUIDTEMPLATE
temp.content {
    template = ...
    variables {
        domain = TEXT
        domain.value = {$myTSconstant}
        :
    }
}

要么

settings { 
    domain = TEXT
    domain.value = {$myTSconstant}
    :
}

如果要在内容元素的数据字段中使用常量,则可以使用标记并将标记替换为活字,作为呈现的最后一步。

"<p>This is my text and here I use a marker: __MYMARKER__</p>"

相应的打字稿:

page {
    :

    stdWrap.replacement {
         1.search = __MYMARKER__
         1.replace = {$myTSconstant}
    }
}

注意:
总是在花括号内的名称前使用带$ TS常量。
不要将其与流体中的可变用法(没有$ )混淆。

关于您的问题:
正如Riccardo提到的那样:甚至不要对链接使用常量,甚至: 不要手动建立链接 如果您确实需要URL中的域,请使用config.absRefPrefix设置(最好是config.baseURL )将其自动化。

我猜您可以使用config.absRefPrefixconfig.baseURL (请参阅https://docs.typo3.org/typo3cms/TyposcriptReference/Setup/Config/

您可以在TypoScript常量中进行设置:

tx_dti.settings.url = http://myserver

然后在TypoScript安装程序中:

config.baseURL = {$tx_dti.settings.url}

要么

config.absRefPrefix = {$tx_dti.settings.url}

这足够了还是我误解了您的要求?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM