François L
François L

Reputation: 99

Subnavigation with title of parent and custom image - TypoScript

Hi everyone
Im new to typoscript and trying to create a subnavigation with a title of the parent and an image defined in the page. The problem is, that I haven't found a possibility, that allows me to pick a specific title or a specific image. This is how i thought about it (i didnt do any wraps on purpose to shorten the examples): The page structure:

P1
  P1a
  P1b
P2
P3
  P3a
  P3b
  P3c

To each main navigation the title will be print in the navigation (P1,P2,P3):

menu = HMENU
menu.entrylevel = 0
menu.1 = TMENU
menu.1.expAll = 1

-> this would be a normal navigation with P1,P2,P3 For the subnavigation I go the second rootline

menu.2 = TMENU

inside the subnavigation (menu.2) i need the picture i defined in resources and the title of the specific parent page. so an ascii view of the subnavigation for P1:

P1                    P2                    P3
----------------- {Pagetitle (in this case P1)}
|Picture defined| P1a
|in resources   | P2a
|of P1          | P3a
-----------------

I know about the prepend function to insert content before the actual items in the subnavigation. What I dont know is how to access a specific parent element. I also tried leveltitle:1 but this is just the title of the current page. So if i would be on P3 and look at the subnavigation of P1 the part in {} would say P3 instead of P1.

I hope the examples have shown what i want to do. I'll continue to research on how to achieve this, but I'd be really glad for help any help :)

Upvotes: 1

Views: 643

Answers (1)

Pim Broens
Pim Broens

Reputation: 702

Sure this is possible, just a little tweaking. I've setup a basic menu with 2 levels, ul/li and image and title included from the parent page, but only if there is a sub through wrapItemAndSub

Not tested, so it might need tweaking

lib.menu = HMENU
lib.menu {
  1 = TMENU
  1 {
    wrap = <ul>|</ul>
    expAll = 1
    NO = 1
    NO {
      wrapItemAndSub = <li>|</li>
    }
  }

  2 = TMENU
  2.stdWrap.wrap.stdWrap.cObject = COA
  2.stdWrap.wrap.stdWrap.cObject {
      20 = FILES
      20 {
        references {
          table = pages
          uid.data = field:pid
          fieldName = media
        }
        renderObj = IMAGE
        renderObj {
          file.import.data = file:current:publicUrl
          altText.data = file:current:title
          wrap = <span class="image">|</span>
        }
      }
      30 = RECORDS
      30 {
        source.data = field:pid
        tables = pages
        conf.pages = TEXT
        conf.pages.field = title
        wrap = <span class="parentTitle">|</span>
      }
  }
  2{
      wrap = <ul>|</ul>
      expAll = 1
      NO{
          wrapItemAndSub = <li>|</li>
      }
  }
}

page = PAGE
page.10 < lib.menu

Upvotes: 3

Related Questions