[TYPO3] how to get Page Number using TS?

Christopher Torgalson bedlamhotel at gmail.com
Tue Jan 23 00:24:54 CET 2007


Hi,

On 1/22/07, David Lanier <mailinglists at davidlanier.com> wrote:
> Does anyone have an idea of how to get the current page number, using
> typoscript?
>
> My scenario is like this:
>
> Page tree:
> - page 1
> - page 2
>   -- subpage 1
>   -- subpage 2
>   -- subpage 3
>   -- subpage 4 (current page)
>   -- subpage 5
> - page 3
> - page 4
> - page 5
>
> I would like to use some typoscript similar to the following, but I have
> not been able to locate it.
> lib.pagenum = TEXT
> lib.pagenum.value = {currentpage.pagenum}
>  // expecting the number "4"
>
> HMENU.special.browse gets close, but I don't think it provides the
> number of the current page.  I'm not looking for the PID of the current
> page, only what number it is within its section.  (I want to use this in
> a javascript in the page header.)


This is not exactly what you need either, but there is something close
available in the register that tells you the number of each menu item.
But if your markup changes from page to page (e.g. if branches of the
menu expand or contract), a given page will not always have the same
'number':

page.77 = HMENU
page.77 {	
	1 = TMENU
	1 {
		noBlur = 1
		expAll = 1
		wrap = <ul>|</ul>
		
		NO = 1
		NO {
			wrapItemAndSub = |</li>
			stdWrap.dataWrap = <li> [page id: {field:uid}][menu item number:
{register:count_HMENU_MENUOBJ}] |
		}
	}
	
	2 < .1
	3 < .1
	4 < .1
}


The example also shows one way to get a page's uid. In general, this
is a more useful item as it can be trusted to be unique.

-- 
Christopher Torgalson


More information about the TYPO3-english mailing list