Zum Inhalt springen

Menu mit Datensatz Anzahl

Erstellt am 29. September 2012 · 1 Antwort · letzte Antwort am 20. November 2012

Tags: Frage

boom404 ·

Hallo.

Ich habe ein normales TMENU

lib.mainmenu = HMENU
lib.mainmenu {
	1 = TMENU
	1 {
				
		expAll = 1
		wrap = <ul>|</ul>
		
		NO {
			linkWrap= <li>|</li>
			ATagTitle.field = abstract // description // title
		}
		ACT < .NO
		ACT = 1
		ACT.ATagParams = class="active"
	}
	
	2 < .1
	2.expAll = 0
	
	3 < .2
		
}

Ich würde nun gern bei Punkt 3 vom Menu noch in Klammern die Datensatz Anzahl von einer Extension Tabelle mit angeben. Das ganze sollte dann so aussehen

Vorher:
Wohnen
Gewerbe
Geld Anlage

Nachher:
Wohnen (25)
Gewerbe (67)
Geld Anlage (0)

Das ganze müsste doch mit "table=tt_content" gehen. Finde aber keinen Ansatz o.O

Wäre schön wenn mir jemand auf die Sprünge hilft.

chris3 ·

Dann helf ich mal springen:

Stichwort ist "LOAD_REGISTER"

http://www.typo3wizard.com/en/snippets/menus/menu-with-recursive-count-of-subpages.html

http://lists.typo3.org/pipermail/typo3-english/2006-January/018415.html

#paralyzed#

EDITH:

...damit sich das auch hier noch findet, wenn die Links mal nicht mehr existieren:

lib.subcountmenu = COA
lib.subcountmenu {
  10 = HMENU
  10.1 = TMENU
  10.1 {
    expAll = 1
    wrap = <ul>|</ul>
    NO {
      stdWrap.cObject = COA
      stdWrap.cObject {
        				# Here we create a couple register vars which contains a accumulated list of all page ids from each level
        10 = LOAD_REGISTER
        				# 1st we collect the page ids of the current level
        10.level1uids.cObject = COA
        10.level1uids.cObject {
          					# We select the ids of pages that have the id of the current page as parent page.	
          					# Except if the page has the "Hide in menu" checkbox is enabled or the pagetype is
          					# either "Not in menu" (5) or "Backend User Section" (6)
          10 = CONTENT
          10.table = pages
          10.select.pidInList.data = field:uid
          10.select.where = nav_hide!=1 AND doktype!=5 AND doktype!=6
          					# Each page id is rendered with a comma at the end, creating a commaseperated list of page ids
          10.renderObj = TEXT
          10.renderObj.field = uid
          10.renderObj.wrap = |,
          					# Finally we add the id of the current page to the list.
          20 = TEXT
          20.data = field:uid	
        }
        				# For the 2nd level we use the list of page ids we generated for the current level
        10.level2uids.cObject < .10.level1uids.cObject
        10.level2uids.cObject.10.select.pidInList.data = register:level1uids
        				# And finally we add the 1st list of ids to the 2nd list.
        10.level2uids.cObject.20.data = register:level1uids
         
        				# For the 3rd level, we repeat the procedure from the 2nd level.
        				# If your site has more than 3 levels, you should repeat the procedure.
        10.level3uids.cObject < .10.level1uids.cObject
        10.level3uids.cObject.10.select.pidInList.data = register:level2uids
        				# And finally we add the 2st list of ids to the 3rd list.
        10.level3uids.cObject.20.data = register:level2uids
         
        				# Here we count the pages, based on the id lists we created and stored in the register var "level3uids"
        				# Note: If you have created more levels in the LOAD_REGISTER object, you should change "level3uids" to the last level you created.
        20 = TEXT
        20.numRows.table = pages
        20.numRows.select.pidInList.data = register:level3uids
        20.numRows.select.where = nav_hide!=1 AND doktype!=5 AND doktype!=6
        				# And output the page title (Using dataWrap to save some codelines ;) ) along with the count of all pages beneath.
        20.dataWrap = {field:title} [|/
         
        				# Here we count and output the number of direct children.
        30 = TEXT
        30.numRows.table = pages
        30.numRows.select.pidInList.field = uid
        30.numRows.select.where = nav_hide!=1 AND doktype!=5 AND doktype!=6
        30.wrap = |]
      }
      wrapItemAndSub = <li>|</li>
    }
  }
  	# Menulevel 2+3 is just copies of the 1st level.
  10.2 < .10.1
  10.3 < .10.1
}
page.100 < lib.subcountmenu

bzw.

-- cut --
lib.test = COA
lib.test {

   # Save the output of numRows in the registervalue: "menuNumber"
  10 = LOAD_REGISTER
  10.menuNumber.numRows {
    table = pages
    select.pidInList.data =  field:uid
  }

  # Retrieve the registervalue and display it.
  20 = TEXT
  20.dataWrap = <div>There are {register:menuNumber} subpages to the page: 
{field:title}</div>

}

page.30 < lib.test
-- cut --