问题描述
首先我的目标是:我想创建一个包含内部页面链接的列表。此列表必须按创建日期(数据库中的 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,没有默认的后端元素对我不起作用,是的,我必须在排版中进行
预先感谢您的任何建议。
解决方法
url
记录中的字段 pages
通常不包含该页面的网址。
它仅用于 external URL
类型的页面,因此可以将指向该页面的内部链接转发到该 URL。
如果您想要所有页面的链接列表,您需要创建指向这些页面的链接:
99 = CONTENT
99 {
table = pages
select {
// your selection here
}
renderObj = TEXT
renderObj {
typolink {
parameter.field = uid
}
}
}
这将为您提供一个完整链接的列表(如果用 renderObj
包裹 <li>|</li>
),其中页面标题作为链接文本。
如果你只想要网址,你可以添加:
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 = |,}
}
}