Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
402 views
in Technique[技术] by (71.8m points)

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)

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.

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

Thanks in advance for any suggestions.

question from:https://stackoverflow.com/questions/65921919/select-urls-from-typo3-database-via-typoscript-query

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The field url in the pages record does not hold the url from that page in general.
It is used only for pages of type external URL, so the internal link to this page can be forwarded to that 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.

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 = |,
      }
   }
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...