[英]Select urls from Typo3 Database via Typoscript query
首先我的目標:我想創建一個包含內部頁面鏈接的列表。 此列表必須按創建日期排序(數據庫中的 crdate)
為此,我編寫了以下代碼:
99 = CONTENT
99.table = pages
99.select {
pidInList = root,-1
selectFields = url
orderBy = crdate
}
可悲的是,這沒有任何回報。 為了調試,我使用了不同的屬性。 和
99 = CONTENT
99.table = tt_content
99.select {
pidInList = 1
orderBy = crdate
}
我克隆了我的根頁面。 我得到了所有的記錄。 所以我知道所有的頁面記錄都應該用 url 存儲在 Pages 表中。
我在這里做錯了什么?
附加信息:Typo3 8.7,沒有默認后端元素對我不起作用,是的,我必須在打字稿中做
在此先感謝您的任何建議。
pages
記錄中的字段url
通常不包含該頁面中的 url。
它僅用於external URL
類型的頁面,因此該頁面的內部鏈接可以轉發到該 url。
如果您想要所有頁面的鏈接列表,您需要創建指向這些頁面的鏈接:
99 = CONTENT
99 {
table = pages
select {
// your selection here
}
renderObj = TEXT
renderObj {
typolink {
parameter.field = uid
}
}
}
這將為您提供一個完整鏈接列表(如果用<li>|</li>
包裝renderObj
),其中頁面標題作為鏈接文本。
如果您只想要網址,您可以添加:
typolink {
returnLast = url
}
如果沒有包裝,它將是一個沒有分離的長字符串。
編輯:
99 = CONTENT
99 {
table = pages
select {
pidInList = 69
orderBy = crdate desc
}
wrap = <ul>|</ul>
renderObj = TEXT
renderObj {
wrap = <li>|</li>
typolink {
parameter.field = uid
}
if.isFalse.cObject = CONTENT
if.isFalse.cObject {
table = pages
select {
// this 'uid' is from context of current pages record we have selected above
pidInList.field = uid
// this 'uid' is the field from the records we are selecting here
selectFields = uid
}
renderObj = TEXT
// this 'uid' is the selected field above
// a field in the pages record of the subquery to decide if there are child pages
renderObj.field = uid
# renderObj.wrap = |,
}
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.