[TYPO3-english] How do you generate a menu where every menu item has its own image, using DAM?

Oliver Salzburg oliver.salzburg at googlemail.com
Thu Jul 12 11:42:50 CEST 2012


On 2012-07-11 20:48, Oliver Salzburg wrote:
> On a clients website, they have a certain navigation elements which I
> plan to replace with a proper TYPO3 menu. But it's proving to be quite
> a challenge.
> 
> - The menu should contain all sub-pages of the page currently being
>   viewed.
> - Every menu item should be rendered with an image that was previously
>   "linked" with the page.
>   - This image must be sourced from DAM so we can make use of file
>     references rather than copies.
> 
> I solved my first requirement by using:
> 
> 	lib.content = HMENU
> 	lib.content {
> 	  special = directory
> 	  special.value.data = page:id
> 
> So far, so good.
> 
> Now the image part boils down to:
> 	10 = IMAGE
> 	10 {
> 	  file {
> 	    import.cObject = USER
> 	    import.cObject {
> 	      userFunc = tx_dam_pages->get_media_file
> 	      listNum  = 0
> 	      slide    = 1
> 	    }
> 	  }
> 	}
> 
> At least, that's the example code from EXT:dam_pages, which I use to
> link DAM records with pages. And it works great, as long as I pass a
> constant uid to it (not shown in the above code).
> 
> So how do I get the page ID in there?
> 
> This is very frustrating, because an approach *without* DAM works
> perfectly. As suggested here:
> http://www.typo3-addict.com/2008/11/gmenu-with-a-different-image-for-each-menu-item/
> 
> But that is simply not an option due to the default file handling
> behavior of TYPO3.
> 
> Cheers
> Oliver
> 

maholtz on StackOverflow (http://stackoverflow.com/a/11447921/259953)
also provides another solution to this, which is very close to what I
originally had in mind:

    10 = IMAGE
    10 {
      file {
        import.cObject = USER
        import.cObject {
          userFunc  = tx_dam_pages->get_media_file
          uid.field = uid
          listNum   = 0
        }
      }
    }

Thanks for all the help :)
Oliver


More information about the TYPO3-english mailing list