[Typo3] pagination possible in "Menu of subpages"

Torsten Schrade schrade at lineara.de
Tue Oct 11 09:52:08 CEST 2005


Hi Dave,

huh, after some racking of brains I have "some" solution for this. Let's 
see if you like it...it's quit a bit of TS:

> We use the "Menu of subpages to these pages" content element a lot within 
> the site to give a list of sub pages within a category, however sometimes we 
> have an awful lot of subpages so the menu becomes too long. Is there a way 
> of adding pagination to the sub pages so for instance if you have 100 
> subpages, you can show 20 at a time with pagination for the menu to show the 
> next 20 etc.

The idea is to limit the general number of items the "Menu of subpages 
to these pages" content element can take using maxItems. Then it is 
checked with stdWrap if the number of pages that are subpages to the 
content element exceeds a given number. If this is true a link with a 
&next= parameter is appended. This parameter is taken up in a condition 
that sets the starting point of the menu to the first in the "second" 
set of menuitems using .begin property of HMENU.

So all you have to do with the following snippet is to define the 
numbers for the "sets" in the .if.value properties and change the 
.values in your conditions accordingly.

1.set

config.linkVars = next

2.Overwrite your default "Menu of subpages to these pages" CE with the 
following snippet, modifying the numbers to your needs.

tt_content.menu.20.1 = HMENU
tt_content.menu.20.1 {

	special = directory
	special.value.field = pages

	# this determines the general number of menuitems that can be shown
	maxItems = 3
	wrap >

	# the following wraps the menu dynamically according to the number of 
existing subpages
	# if the number is greater than .value it appends a &next= parameter 
that is taken up in a condition

	stdWrap.innerWrap = <div class="csc-menu csc-menu-1">|</div>
	stdWrap.innerWrap.if {
			value = 4
			isLessThan.cObject = TEXT
			isLessThan.cObject.numRows {
        				table = pages
        				select {
           				pidInList.data < tt_content.menu.20.1.special.value.field
           				orderBy = sorting
					selectFields = uid
        				}
     			}
		}
	stdWrap.outerWrap = <div class="csc-menu csc-menu-1">|<p><a 
href="index.php?{TSFE:id}&next=1">next...</a></p></div>
	stdWrap.outerWrap.insertData = 1
	stdWrap.outerWrap.if {
				value = 3
				isGreaterThan.cObject < 
tt_content.menu.20.1.stdWrap.innerWrap.if.isLessThan.cObject
				}

	1 = TMENU
	1.target=_top
	1.NO {
		allWrap = <p>|</p>
		stdWrap.htmlSpecialChars=1
	}		
}

3. Set the conditions in your template and change the values accordingly:

####################
[globalVar = GP:next = 1]

# this condition sets the starting point for the second "set" of 
menuitems and appends a next- or backlink accordingly

tt_content.menu.20.1 {
	begin = 4
	stdWrap {
		innerWrap.if.value = 7
		innerWrap = <div class="csc-menu csc-menu-1">|<p><a 
href="index.php?{TSFE:id}">back...</a></p></div>
		innerWrap.insertData = 1

		outerWrap = <div class="csc-menu csc-menu-1">|<p><a 
href="index.php?{TSFE:id}&next=2">next...</a></p></div>
		outerWrap.if.value = 6
	}
[global]

####################
[globalVar = GP:next = 2]

# this condition sets the starting point for the third "set" of 
menuitems and appends a next- or backlink accordingly

tt_content.menu.20.1 {
	begin = 7
	stdWrap {
		innerWrap.if.value = 10
		innerWrap = <div class="csc-menu csc-menu-1">|<p><a 
href="index.php?{TSFE:id}&next=1">back...</a></p></div>
		innerWrap.insertData = 1

		outerWrap = <div class="csc-menu csc-menu-1">|<p><a 
href="index.php?{TSFE:id}&next=3">next...</a></p></div>
		outerWrap.if.value = 9
	}
[global]

####################

As you can see in my example I tested it successfully with a page that 
had nine subpages, taking steps of three menuitems each time. Hope the 
whole thing somehow makes sense :-)

Have fun and greets,
Torsten



More information about the TYPO3-english mailing list