简体   繁体   English

通过 Typoscript 查询来自 Typo3 数据库的 Select url

[英]Select urls from Typo3 Database via Typoscript query

First my goal: I want to create a list with links to internal pages.首先我的目标:我想创建一个包含内部页面链接的列表。 This list has to be ordered by creation date (crdate in the DB)此列表必须按创建日期排序(数据库中的 crdate)

To achieve this, I wrote the following code:为此,我编写了以下代码:

99 = CONTENT
99.table = pages
99.select {
    pidInList = root,-1
    selectFields = url
    orderBy = crdate
}

Sadly, this returns nothing.可悲的是,这没有任何回报。 For debugging I played with the different properties.为了调试,我使用了不同的属性。 With

99 = CONTENT
99.table = tt_content
99.select {
    pidInList = 1
    orderBy = crdate
}

I cloned my rootpage.我克隆了我的根页面。 I got all records from it.我得到了所有的记录。 So I know that all page records should be stored in the Pages table with the url.所以我知道所有的页面记录都应该用 url 存储在 Pages 表中。

What am I doing wrong here?我在这里做错了什么?

Additional information: Typo3 8.7, no the default backend elements are not working for me, yes I have to do it in typoscript附加信息:Typo3 8.7,没有默认后端元素对我不起作用,是的,我必须在打字稿中做

Thanks in advance for any suggestions.在此先感谢您的任何建议。

The field url in the pages record does not hold the url from that page in general. pages记录中的字段url通常不包含该页面中的 url。
It is used only for pages of type external URL , so the internal link to this page can be forwarded to that url.它仅用于external URL类型的页面,因此该页面的内部链接可以转发到该 url。

If you want a link list of all your pages you need to create a link to these pages:如果您想要所有页面的链接列表,您需要创建指向这些页面的链接:

99 = CONTENT
99 {
   table = pages
   select {
      // your selection here
   }

   renderObj = TEXT
   renderObj {
      typolink {
         parameter.field = uid
      }
   }
}

This will give you a list (if wrapping the renderObj with <li>|</li> ) of complete links with page title as link text.这将为您提供一个完整链接列表(如果用<li>|</li>包装renderObj ),其中页面标题作为链接文本。

If you want only urls you can add:如果您只想要网址,您可以添加:

typolink {
   returnLast = url
}

Without wrapping it will be a long string without separation.如果没有包装,它将是一个没有分离的长字符串。


EDIT:编辑:

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM