[TYPO3] counting subpages recursivly?

Peter Klein peter at umloud.dk
Sun Jun 24 00:57:45 CEST 2007


Hi Bernd.
This can be done by creating a list of page ids for subpages and their 
subpages. In the example below the list of ids for each level is stored in a 
seperate register value.

-- cut --
lib.subcountmenu = COA
lib.subcountmenu {
 10 = HMENU
 10.1 = TMENU
 10.1 {
  expAll = 1
  wrap = <ul>|</ul>
  NO {
   stdWrap.cObject = COA
   stdWrap.cObject {
    10 = LOAD_REGISTER
    10.level1uids.cObject = COA
    10.level1uids.cObject {
     10 = CONTENT
     10.table = pages
     10.select.pidInList.data = field:uid
     10.renderObj = TEXT
     10.renderObj.field = uid
     10.renderObj.wrap = |,
     20 = TEXT
     20.field = uid
    }
    10.level2uids.cObject < .10.level1uids.cObject
    10.level2uids.cObject.10.select.pidInList.data = register:level1uids
    10.level2uids.cObject.20.data = register:level1uids
    10.level3uids.cObject < .10.level1uids.cObject
    10.level3uids.cObject.10.select.pidInList.data = register:level2uids
    10.level3uids.cObject.20.data = register:level2uids

    20 = TEXT
    20.numRows.table = pages
    20.numRows.select.pidInList.data = register:level3uids
    20.dataWrap = {field:title} [|/

    30 = TEXT
    30.numRows.table = pages
    30.numRows.select.pidInList.field = uid
    30.wrap = |]
   }
   wrapItemAndSub = <li>|</li>
  }
 }
 10.2 < .10.1
 10.3 < .10.1
}
page.65 < lib.subcountmenu
-- cut --

This should work with a 3 level menu structure. If you need more levels, 
you'll have to add a "level4uids", "level5uids" in the LOAD_REGISTER object, 
similar to the ones for "level2uids" and "level3uids", and then use that 
register value in the 20 object.

--
Peter Klein / Umloud Untd.

"Bernd Wilke" <xoonsji02 at sneakemail.com> wrote in message 
news:mailman.1.1182540689.24631.typo3-english at lists.netfielders.de...
> Hello,
>
> I want to display in my menus the count of subpages to each page.
>
> I have finished the first iteration:
> count of pages which are direct children.
> (see my HP (german!))
>
> But my idea was the count of all pages beneath every page.
>
> example:
>
> root (13/3)
> +-page (3/2)
> |  +-page (1/1)
> |  |  +-page (0/0)
> |  +-page (0/0)
> +-page (6/3)
> |  +-page (3/2)
> |  |  +-page (0/0)
> |  |  +-page (1/1)
> |  |     +-page (0/0)
> |  +-page (0/0)
> |  +-page (0/0)
> +-page (1/1)
>    +-page (0/0)
>
> The first number gives the count of all pages beneath
> the second number gives the number of direct children
>
> the whole would be easy in php (extension or userfunc), but maybe someone
> knows a way to solve it with pure typoscript?
>
> Bernd
> -- 
> http://www.pi-phi.de/t3v4/cheatsheet.html 




More information about the TYPO3-english mailing list