[Typo3] Doing a select statement from typoscript

Ries van Twisk typo3 at rvt.dds.nl
Thu Sep 29 17:48:10 CEST 2005


het all,

I need to do select of ALL pages using typoscript

When I try to do the following
(Please note that the where clause test allows me to see what SQL is 
generated by typo3, it generates and show a error when heaving SQL debug 
on and so it is intentional).

        select {
            pidInList =
            uidInList =
            orderBy = crdate DESC
            where = test
            max = 7
        }

I alse tried this:
        select {
            pidInList >
            uidInList >
            orderBy = crdate DESC
            where = test
            max = 7
        }

I generated this SQL:
SELECT *
FROM pages
WHERE
pages.pid IN (86) AND test AND pages.deleted=0 AND pages.hidden=0 AND 
(pages.starttime<=1128002481) AND (pages.endtime=0 OR 
pages.endtime>1128002481) AND doktype<200 AND fe_group IN (0,-1)
ORDER BY crdate DESC

What I need is that typoscript generates a list of the last 7 additions 
in my page tree  (I need to get rid of pages.pid IN (86) )

When I use this TS:

newPages = COA
newPages {
    10 = LOAD_REGISTER
    10 {
        lvl1uids.cObject = CONTENT
        lvl1uids.cObject {
            table=pages
            select.pidInList = this
            renderObj = TEXT
            renderObj.field = uid
            renderObj.wrap = |,
        }
        lvl2uids < .lvl1uids
        lvl2uids.cObject.select.pidInList.data= register:lvl1uids
        lvl3uids < .lvl1uids
        lvl3uids.cObject.select.pidInList.data= register:lvl2uids
        lvl4uids < .lvl1uids
        lvl4uids.cObject.select.pidInList.data= register:lvl3uids
        lvl5uids < .lvl1uids
        lvl5uids.cObject.select.pidInList.data= register:lvl4uids
        lvl6uids < .lvl1uids
        lvl6uids.cObject.select.pidInList.data= register:lvl5uids
        lvl7uids < .lvl1uids
        lvl7uids.cObject.select.pidInList.data= register:lvl6uids
        lvl8uids < .lvl1uids
        lvl8uids.cObject.select.pidInList.data= register:lvl7uids
        alluids.cObject = COA
        alluids.cObject {
            10=TEXT
            10.data = register:lvl1uids
            20=TEXT
            20.data = register:lvl2uids
            30=TEXT
            30.data = register:lvl3uids
            40=TEXT
            40.data = register:lvl4uids
            50=TEXT
            50.data = register:lvl5uids
            60=TEXT
            60.data = register:lvl6uids
            70=TEXT
            70.data = register:lvl8uids
            80=TEXT
            80.data = register:lvl9uids
            90=TEXT
            90.data = leveluid:-1
        }
   
    }
    20 = CONTENT
    20 {
        table = pages
        select {
            pidInList.data = register:alluids
            orderBy = crdate DESC
            where = test AND pid != 86 AND crdate > (UNIX_TIMESTAMP() - 
5184000)
            where = test
            max = 7
        }
       
        renderObj = COA
        renderObj {
            10 = TEXT
            10.field = title
            10.typolink.parameter.field=uid
            10.typolink.parameter.stdWrap.dataWrap=#uid
            10.typolink.userFunc = tx_ltgextendedmenus_pi1->ts_addTitletag
            10.wrap = <div class="style1 style4 style6">|</div>
        }
    }
    wrap = <div class="style1">Latest additions in ###title-1###</div>|
}

The generated SQL is HUGE!!! Since it does something like this:
SELECT *
FROM pages
WHERE
pages.pid IN 
(101366,101367,80,82,72,...........................................)
AND TEST AND pid != 86 AND crdate > (UNIX_TIMESTAMP() - 5184000) AND 
pages.deleted=0 AND pages.hidden=0 AND (pages.starttime<=1128002913) AND 
(pages.endtime=0 OR pages.endtime>1128002913) AND doktype<200 AND 
fe_group IN (0,-1)
GROUP BY uid
ORDER BY crdate DESC
LIMIT 7

I don't show all page UID's, but with 1370 pages and still growing this 
doesn't sound that effective.

Does anybody know a better solution for this?

regards,
Ries van Twisk



More information about the TYPO3-english mailing list