[TYPO3-english] Get current page ID in menu.

Christopher Torgalson bedlamhotel at gmail.com
Thu Oct 29 16:01:01 CET 2009


Hi there,

On Thu, Oct 29, 2009 at 2:20 AM, Rudy Gnodde (WIND Internet)
<rgn at windinternet.nl> wrote:
> Hello Radoslav,
>
> Radoslav Kolarov wrote:
>>
>> Hi, I need to get current page in menu to make it dynamic. Here is the
>> code:
>>
>> ...
>> special = directory
>> special.value = [current_page_id]
>> entryLevel = 0
>> .....
>>
>> So I'll show the subpages of current page in this menu.
>> Please tell me how to get this pageid.
>> Thanks
>
> special.value has stdWrap, so you can set special.value.data = TSFE:id. I
> haven't tried it, but something like that should work.


While this is true, there should be no need for any such code to make
subpages of a menu show since this is the *default* behaviour.

Radoslav, I don't know if it's the source of whatever problem you're
having, but your TS contains an error. The .special property and
.entryLevel should NOT be used together. See the TSref:

"NOTE: Don't set .entryLevel for a HMENU when using this [.special]
option! Also be aware that this selects pages for the first level in
the menu. Submenus by menuPbjects 2+ will be created as usual." [1]

A basic TS menu with two levels of subpages just looks like this:

lib.some_menu = HMENU
lib.some_menu {
  special = directory

  1 = TMENU
  1 {
    noBlur = 1
    wrap = <ul id="some-menu">|</ul>

    NO {
      wrapItemAndSub = <li>|</li>
    }

    CUR = 1
    CUR {
      ATagParams = class="current"
    }
  }

  2 < .1
  2.wrap = <ul>|</ul>

  3 < .2
}

Try adapting that menu and if you still have problems reply back to this thread.

[1] http://typo3.org/documentation/document-library/references/doc_core_tsref/4.2.0/view/1/8/#id4251386

-- 
Christopher Torgalson
http://www.typo3apprentice.com/


More information about the TYPO3-english mailing list