我想在我的模板鏈接到第一個子頁面(這是一個部分概述頁面,所以總會有子頁面可用)。該鏈接將始終具有相同的文本。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