Typo3 中的 TMENU - 从上一层插入 url
TMENU in Typo3 - insert url from level above
我有一个 TMENU
,在该菜单中,我想将 "Level 1" 中的 URL 插入到 "Level 2" 中的 wrap
项中。
当前的 TypoScript 如下所示:
10 = HMENU
10 {
1 = TMENU
1 {
expAll = 1
NO = 1
NO.allWrap = <li>|</li>
NO.allWrap.insertData = 1
NO.ATagTitle.field = abstract // description // title
}
2 = TMENU
2 {
expAll = 1
stdWrap.wrap = <ul><li><a href="*****URL FROM LEVEL 1 SHOULD BE HERE*****"></a></li>|</ul>
NO = 1
NO.allWrap = <li>|</li>
NO.allWrap.insertData = 1
NO.ATagTitle.field = abstract // description // title
}
}
有什么提示吗?感谢您的帮助!
stdWrap
属性按定义的顺序执行(如文档中所示),请参阅 https://docs.typo3.org/m/typo3/reference-typoscript/master/en-us/Functions/Stdwrap.html#prepend
知道 prepend
在 wrap3
之前执行可以解决这个挑战。
page = PAGE
page.10 = HMENU
page.10 {
1 = TMENU
1 {
expAll = 1
NO = 1
NO.allWrap = <li>|</li>
NO.allWrap.insertData = 1
NO.ATagTitle.field = abstract // description // title
}
2 = TMENU
2 {
expAll = 1
stdWrap.prepend = TEXT
stdWrap.prepend {
# remove `value` if page title shall be used
value = URL from Level 1
# using <current-page>.pid value pointing to previous level
typolink.parameter.field = pid
wrap = <li>|</li>
}
# `wrap3` is executed after `prepend`
stdWrap.wrap3 = <ul>|</ul>
NO = 1
NO.allWrap = <li>|</li>
NO.allWrap.insertData = 1
NO.ATagTitle.field = abstract // description // title
}
}
在这样的页面树上
+- A
| +- AA
| +- AB
|
+- B
+- BA
+- BB
呈现的 HTML 结果如下所示
<li><a href="/ts/a" title="A">A</a></li>
<ul>
<li><a href="/ts/a">URL from Level 1</a></li>
<li><a href="/ts/a/aa" title="AA">AA</a></li>
<li><a href="/ts/a/ab" title="AB">AB</a></li>
</ul>
<li><a href="/ts/b" title="B">B</a></li>
<ul>
<li><a href="/ts/b">URL from Level 1</a></li>
<li><a href="/ts/b/ba" title="BA">BA</a></li>
<li><a href="/ts/b/bb" title="BB">BB</a></li>
</ul>
有关替换静态的自定义呈现的更新 value
属性
除了使用 属性 stdWrap.prepend.value
(如上例所示),也可以使用其他 cObject
指令 - 例如在本例中 RECORDS
(见 https://docs.typo3.org/m/typo3/reference-typoscript/master/en-us/ContentObjects/Records/Index.html)
以下示例呈现父页面的字段 nav_title
(如果未定义 title
作为后备)。
page.10 {
# ...
2 {
# ...
stdWrap.prepend {
# using `cObject` instead of `value`
cObject = RECORDS
cObject {
tables = pages
source.field = pid
# rendering definition for retrieved record of table pages
conf.pages = TEXT
# `//` is used as fallback delimiter here, NOT as comment
conf.pages.field = nav_title // title
}
# ...
我有一个 TMENU
,在该菜单中,我想将 "Level 1" 中的 URL 插入到 "Level 2" 中的 wrap
项中。
当前的 TypoScript 如下所示:
10 = HMENU
10 {
1 = TMENU
1 {
expAll = 1
NO = 1
NO.allWrap = <li>|</li>
NO.allWrap.insertData = 1
NO.ATagTitle.field = abstract // description // title
}
2 = TMENU
2 {
expAll = 1
stdWrap.wrap = <ul><li><a href="*****URL FROM LEVEL 1 SHOULD BE HERE*****"></a></li>|</ul>
NO = 1
NO.allWrap = <li>|</li>
NO.allWrap.insertData = 1
NO.ATagTitle.field = abstract // description // title
}
}
有什么提示吗?感谢您的帮助!
stdWrap
属性按定义的顺序执行(如文档中所示),请参阅 https://docs.typo3.org/m/typo3/reference-typoscript/master/en-us/Functions/Stdwrap.html#prepend
知道 prepend
在 wrap3
之前执行可以解决这个挑战。
page = PAGE
page.10 = HMENU
page.10 {
1 = TMENU
1 {
expAll = 1
NO = 1
NO.allWrap = <li>|</li>
NO.allWrap.insertData = 1
NO.ATagTitle.field = abstract // description // title
}
2 = TMENU
2 {
expAll = 1
stdWrap.prepend = TEXT
stdWrap.prepend {
# remove `value` if page title shall be used
value = URL from Level 1
# using <current-page>.pid value pointing to previous level
typolink.parameter.field = pid
wrap = <li>|</li>
}
# `wrap3` is executed after `prepend`
stdWrap.wrap3 = <ul>|</ul>
NO = 1
NO.allWrap = <li>|</li>
NO.allWrap.insertData = 1
NO.ATagTitle.field = abstract // description // title
}
}
在这样的页面树上
+- A
| +- AA
| +- AB
|
+- B
+- BA
+- BB
呈现的 HTML 结果如下所示
<li><a href="/ts/a" title="A">A</a></li>
<ul>
<li><a href="/ts/a">URL from Level 1</a></li>
<li><a href="/ts/a/aa" title="AA">AA</a></li>
<li><a href="/ts/a/ab" title="AB">AB</a></li>
</ul>
<li><a href="/ts/b" title="B">B</a></li>
<ul>
<li><a href="/ts/b">URL from Level 1</a></li>
<li><a href="/ts/b/ba" title="BA">BA</a></li>
<li><a href="/ts/b/bb" title="BB">BB</a></li>
</ul>
有关替换静态的自定义呈现的更新 value
属性
除了使用 属性 stdWrap.prepend.value
(如上例所示),也可以使用其他 cObject
指令 - 例如在本例中 RECORDS
(见 https://docs.typo3.org/m/typo3/reference-typoscript/master/en-us/ContentObjects/Records/Index.html)
以下示例呈现父页面的字段 nav_title
(如果未定义 title
作为后备)。
page.10 {
# ...
2 {
# ...
stdWrap.prepend {
# using `cObject` instead of `value`
cObject = RECORDS
cObject {
tables = pages
source.field = pid
# rendering definition for retrieved record of table pages
conf.pages = TEXT
# `//` is used as fallback delimiter here, NOT as comment
conf.pages.field = nav_title // title
}
# ...