Zum Inhalt springen

Menue mit Umbruch

Erstellt am 24. August 2011 · 3 Antworten · letzte Antwort am 26. August 2011

Tags: Frage

Danii ·

Ich bin sicher, dass das schon besprochen wurde. Gefunden hab ich leider noch nichts dazu.

Ich brauche ein List-Menue nach folgender Struktur

eins . vier . sieben
zwei . fünf . usw
drei . sechs

das müsste also irgendwie ein Counterconstrukt sein, das mir nach drei Einträgen die <ul> schliesst und eine neue öffnet.

Ich steh grad aufm Schlauch (hat ja auch grad 34 Grad Hitze) :o

Hat jemand eine Initialidee für mich?

Chrissli ·

Hallo Danii,

das Wetter haut halt recht rein 😃
Das Stichwort lautet "optionSplit",
kannst mal in der TSref nachschlagen.
Bis dahin sollte dir das weiterhelfen:

10 = HMENU
10 {
  1 = TMENU
  1.NO = 1    
  stdWrap = <ul><li>|</li> |*| <li>|</li> || <li>|</li> || <li>|</li></ul><ul> |*| <li>|</li></ul>
}

Ich hoffe das kommt so hin...

Danii ·

Hi,

optionSplit ist mir an der Stelle zu unflexibel. Ich hab's gestern testweise so gemacht.

temp.listmenue  = COA
temp.listmenue {
 
  10 = HMENU
  10.special = directory
  10.special.value = 16
  10 {
      maxItems = 3
      1 = TMENU
      1 {
        expAll = 0
        wrap = <ul style="float:left; padding: 10px;">|</ul>
        NO = 1
        NO {
            wrapItemAndSub = <li>|</li>
        }
 
        ACT = 1
        ACT {
            wrapItemAndSub = <li>|</li>
        }
    }
  }
 
  20 < .10
  20.begin = 4
 
  30 < .10
  30.begin = 7
 
  40 < .10
  40.begin = 10
 
}

Ist mir zwar auch noch zu unflexibel weil die Anzahl der Links ungefähr bekannt sein muss, ich such aber weiter.

Chrissli ·

Wie wär's dann mit einem User-Script?
So würde ich's machen, bin mir aber nicht sicher ob sich das HMENU als Parameter mitgeben lässt,
denke aber schon.
Schlimmstenfalls müsste man dieses noch Konvertieren ( weiß nicht ob Typo3 hier eine Textvariable weiterreicht oder
für HMENU ein Object erstellt, kann das leider grade nicht prüfen )

page.includeLibs = fileadmin/scripts/user_customWrapper.php 

temp.listmenue = USER_INT
temp.listmenu {
  userFunc = user_customWrapper->main
  list = HMENU
  list {
    special = directory
    special.value = 16
    1 = TMENU
    1 {
      NO = 1
      NO.doNotLinkIt = 1
      NO.stdWrap.field = uid
      NO.stdwrap = |*| |, |*| |
    }   
  }
  maxItemsBeforeWrap = 3
  userItemWrap = <li>|</li>
  userWrap = <ul>|</ul> 
  fillIfNotMax = 1
}
#Inhalt von fileadmin/scripts/user_customWrapper.php 
<?php

class user_customWrapper {
  public function main($content,$conf) {
    if(!isset($conf['list'])) { return $content; }
		
	//elemente pro reihe
	if(isset($conf['maxItemsBeforeWrap'])) { 
		$itemsPerLine = (int)$conf['maxItemsBeforeWrap'];
	} else { $itemsPerLine = 3; }
	
	//wrap element
	if(isset($conf['userItemWrap'])) {
		$itemWrap = $conf['userItemWrap'];
	} else { $itemWrap = '|'; }
	
	//wrap reihe
	if(isset($conf['userWrap'])) {
		$wrap = $conf['userWrap'];
	} else { $wrap = '|'; }
	
	//auffuellen wenn reihe nicht voll
	if(isset($conf['fillIfNotMax'])) {
		$fill = (bool)$conf['fillIfNotMax'];
	} else { $fill = false; }
	
	$items = explode(',',$conf['list']);
	
	foreach($items as $item) {		
		//element wrap
		$line[] = preg_replace('/\|/',$item,$itemWrap);		
		if(count($line) == $itemsPerLine) {
			//line wrap
			$lines[] = preg_replace('/\|/',implode('',$line),$wrap);
			unset($line);
		}
	}
	if(isset($line)) {		
		if($fill) { //reihe auffuellen
			while( count($line) != $itemsPerLine ) {
				$line[] = preg_replace('/\|/','',$itemWrap);		
			}
		}
		$lines[] = preg_replace('/\|/',implode('',$line),$wrap);
	}
	
	if(isset($lines)) {
		$content .= implode('',$lines);
	}
	
	return $content;
  }
}

?>

[edit]
Musste den PHP-Code korrigieren wg. preg_replace, sollte jetzt aber passen