typo3-获取分裂字符串的最后一个元素
尝试获取 url 的最后一部分作为主体类。到目前为止,我得到了页面的 slug 并将其按 / 分割
page.bodyTag >
page.bodyTagCObject = TEXT
page.bodyTagCObject.field = slug
page.bodyTagCObject.split {
token = /
cObjNum = 1
1.10 = TEXT
1.10.current = 1
1.10.noTrimWrap = | ||
1.10.dataWrap = |
1.10.required = 1
}
使用此代码,我得到: url: page/foo/bar/
class="page foo bar"
我需要获取 class="bar"
Trying to get the last part of the url as a body class. So far I got the slug of the page and split it by /
page.bodyTag >
page.bodyTagCObject = TEXT
page.bodyTagCObject.field = slug
page.bodyTagCObject.split {
token = /
cObjNum = 1
1.10 = TEXT
1.10.current = 1
1.10.noTrimWrap = | ||
1.10.dataWrap = |
1.10.required = 1
}
With this code, I am getting:
url: page/foo/bar/
class="page foo bar"
I need to get class="bar"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要使用 optionSplit< /a> 为此。例如:
<代码>1 |*| 2 |*| 3 表示:第一项使用 1,最后一项使用 3,其余项使用 2。
你可以不设置你不想要的,所以这只会显示最后一项:
You'll need to use optionSplit for that. For example:
1 |*| 2 |*| 3
means: use 1 for the first item, 3 for the last item and 2 for the rest.You can just not set the ones you don't want, so this will only show the last item: