Menu mit rekursiven Zähler für Unterseiten

Übermittlung Ihrer Stimme...
Bewertungen: 3.6 von 5. 10 Stimme(n).
Klicken Sie auf den Bewertungsbalken, um diesen Artikel zu bewerten.

In diesem Menü soll die Anzahl der der direkten Unterseiten und die gesamte Anzahl der Seiten unter jeder Zeile angezeigt werden.

Beispiel:

root (13/3)
+-Seite (3/2)
| +-Seite (1/1)
| | +-Seite (0/0)
| +-Seite (0/0)
+-Seite (6/3)
| +-Seite (3/2)
| | +-Seite (0/0)
| | +-Seite (1/1)
| | +-Seite (0/0)
| +-Seite (0/0)
| +-Seite (0/0)
+-Seite (1/1)
  +-Seite (0/0)

Die erste Zahl stellt die Anzahl aller Seiten unter dieser Seite dar.
Die zweite Zahl stellt die Anzahl der direkten Unterseiten dar.

Dies kann erreicht werden, indem man eine Liste von Seiten ids,für die Unterseiten und die Unterseiten der Unterseiten erstellt.
In diesem Beispiel wird die Liste für jede Ebene in einem seperaten Register gespeichert.

 

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

 

Dieses Snippet wurde von Peter Klein eingesendet



Comments


Keine Kommentare

Kommentar hinzufügen

* - Pflichtfeld

*



*
*

Top 10 Updates

Nützliche Links geändert am  24-Apr-2013 06:31:02
Login geändert am  09-Sep-2010 09:31:35
Schöne Schriften mit Google Font API geändert am  20-May-2010 14:36:59
TS basierte Searchbox für Indexed Search geändert am  18-May-2010 16:26:54
TYPO3 SEO geändert am  30-Apr-2010 07:43:20
Suchmaschinenfreundliche grafische Überschriften in TYPO3 geändert am  30-Apr-2010 07:33:56
Erstellen eines einfachen Infocenters mit TYPO3  geändert am  17-Nov-2009 11:11:22
Funktionierendes Section Menu mit TemplaVoila geändert am  05-May-2009 10:42:40
"Nicht im Menü" in Sitemap anzeigen geändert am  05-May-2009 10:12:24
Implementation des DHTML Menüs von brainjar.com  geändert am  01-Feb-2009 13:01:36

Latest comments

29-Apr-2013 14:34:11
Dierk Hagedorn schrieb: Uff. Besten Dank. Das hat mich gerettet.
Seitentitel ändern
26-Apr-2013 06:36:48
BoBa schrieb: Thank you Rob!
Benutzen des Layout Feldes in tt_content und pages
25-Apr-2013 09:25:28
Oliver Schmid schrieb: Ah.. jetzt gehts, ich hatte die Konstanten im Typoscript Setup eingetragen ;-)
TS basierte Searchbox für Indexed Search
English
Suche: