我想在我的模板链接到第一个子页面(这是一个部分概述页面,所以总会有子页面可用)。该链接将始终具有相同的文本。Typoscript:如何获取当前页面的第一个子页面的ID?
如何获取第一个子页面的ID?
pagelink = TEXT
pagelink {
value = Link to first child page
typolink {
parameter = [[id of first child page]]
}
}
我想在我的模板链接到第一个子页面(这是一个部分概述页面,所以总会有子页面可用)。该链接将始终具有相同的文本。Typoscript:如何获取当前页面的第一个子页面的ID?
如何获取第一个子页面的ID?
pagelink = TEXT
pagelink {
value = Link to first child page
typolink {
parameter = [[id of first child page]]
}
}
这里有一个简单的解决方案:
pagelink = HMENU
pagelink {
# only display if there is a subpage
stdWrap.required = 1
# with value directory, the default special.value is the current page id
special = directory
# limit to 1 page
maxItems = 1
# link item
1 = TMENU
1 {
NO = 1
}
}
要覆盖网页的标题,用这个:
pageLink = HMENU
pageLink {
# only display if there is a subpage
stdWrap.required = 1
# with value directory, the default special.value is the current page id
special = directory
# limit to 1 page
maxItems = 1
# link item
1 = TMENU
1 {
NO = 1
NO {
doNotLinkIt = 1
stdWrap.cObject = TEXT
stdWrap.cObject {
typolink.parameter.field = uid
# override text of menu item
value = Dummy Text
}
}
}
}
有几种方法可以做到这一点(例如,使用HMENU),但我会去为这一个,因为它是明确和容易,如果你一旦决定,使之更加复杂的修改(比如在页面标题某处文本链接,基于媒体字段渲染缩略图)。
pagelink = CONTENT
pagelink {
table = pages
select {
pidInList = this
orderBy = sorting ASC
max = 1
}
renderObj = TEXT
renderObj {
value = Link to first child page
typolink {
parameter.field = uid
}
}
}
注意
value = Link to first child page
与field = title
好的,谢谢。给我正确的链接。你能告诉我如何替换菜单项中的页面标题吗?或者我必须用CSS隐藏它并使用换行来显示我需要的文本? – Tim
@Tim是的,我把它添加到我的文章。 – Shufla