Andreas
Andreas

Reputation: 462

TYPO3 select dropdown of all pages (level 1 and 2)

I'm currently struggling with typoscript. What i need to archive is to have a select box with all pages (level 1, level 2) of a certain page.

So, let's assume i have a page called "Products", this has the subitems "Product 1" and "Product 2". Both, "Product 1" and "Product 2" have other subitems of their own.

Now, i got the following script:

temp.drop_down_box = COA
temp.drop_down_box {
  10 = HMENU
  10 {
     # Special menu type 'directory': Get subpages of the current page
     special = directory
     # '123' is the uid of the page, for which the subpages shall be listed in the drop down box
     special.value = 35
     # Select box with JavaScript event 'onChange' that enables a jump to the target page, once an entry has been selected in the list
     wrap = <select name="dropdown_navigation" size="1" onChange="document.location.href='index.php?id=' + this.value">|</select>
     1 = TMENU
     1 {
       expAll = 1
       noBlur = 1
       NO {
         # 'value' holds the uid of the page in the list (is later appended to the target URL above)
         stdWrap.dataWrap = <option value="{field:uid}">
         allWrap = |</option>
         # Don't wrap the items in link tags
         doNotLinkIt = 1
       }
       # Inherit the 'allWrap' and 'doNotLinkIt' settings from the NO part
       CUR < copy">.NO
       CUR = 1
       CUR {
       # If we're on the current page, mark this list entry as 'selected'
         stdWrap.dataWrap = <option value="{field:uid}" selected="selected">
       }
     }
  }
}

It's working just fine, but only on one level. I'd like to have it that way:

Product
- Product 1
  - Item 1
  - Item 2
  - Item 3
  - Item 4
- Product 2
  - Item 1
  - Item 2
  - Item 3

... and so on.

Is there any way to do this?

Best regards, Andreas

* EDIT: Got it working:

temp.drop_down_box = COA
temp.drop_down_box {
  10 = HMENU
  10 {

    // ... {code from first part of question here} ...
    // additional levels copying 1 level and changing required values

    2 < .1
    2.NO.linkWrap = <option value="{field:uid}">-- |</option>

    3 < .1
    3.NO.linkWrap = <option value="{field:uid}">---- |</option>

  }
}

Upvotes: 1

Views: 1236

Answers (1)

biesior
biesior

Reputation: 55798

For each menu level you need to add next TMENU declaration:

1 = TMENU
1 {
   ...
}

2 = TMENU
2 {
   ...
}

99 = TMENU
99 {
   ...
}

Upvotes: 2

Related Questions