[英]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.