[TYPO3-dev] Add new Parameter to pi_list_modeSelector

Christian Tauscher cms at media-distillery.de
Mon Oct 30 23:17:36 CET 2006


Hello dear TYPO3 developers!

I am not shure if I am right here - it's worth a try.

You all know the pi_list_modeSelector of TYPO3 in Extentions.

I love ist and I use it for more than only makeing diverent views 
possible. But even in this case having all Modes in one line the 
rendered Table will often be faaaar toooooo wide for the Scren. Only 
think of Long names for your Modes.

So I patched the funktion a bit, adding a new parameter to the funktion, 
to enable not only one Row with all Modes in it.

Maybe this is some enhancement that is usefull for other programmers too.

Since I am not a 100% Programmer (I studied Chemistry! Nobody really 
knows how I got into the Web-Business) the code might not be as good as 
it could be but it works for me.

Maybe you are the person to make it a real TYPO3is funktion and send it 
to the Core-Developers (I have now idea how to do so), or you let me 
know what you think about this.

The Code is below, you will know about the few lines I habe added.

Enyou the night (best time for coding),


Christian.


/**
  * Returns a mode selector; a little menu in a table normally put in 
the top of the page/list.
  *
  * @param	array		Key/Value pairs for the menu; keys are the 
piVars[mode] values and the "values" are the labels for them.
  * @param	string		Attributes for the table tag which is wrapped around 
the table cells containing the menu
  * @return	string		Output HTML, wrapped in <div>-tags with a class 
attribute
  */
function pi_list_modeSelector($items=array(),$tableParams='',$rows=1)
	{
	$count = count($items);
	$perRow = (int)($count / $rows) + ($count % $rows);

	$cells=array();
	reset($items);
	$i = 0;
	$n = 0;
	while(list($k,$v)=each($items))	
		{
		$cells[$n][] .= '
<td'.($this->piVars['mode']==$k?$this->pi_classParam('modeSelector-SCell'):'').'><p>'.
$this->pi_linkTP_keepPIvars(htmlspecialchars($v),array('mode'=>$k),$this->pi_isOnlyFields($this->pi_isOnlyFields)).
		'</p></td>';
		$i++;
		if($i == $perRow)
			{
			$n++;
			$i=0;
			}
		}

	$sTables = '
	<!--
		Mode selector (menu for list):
	-->
	<div'.$this->pi_classParam('modeSelector').'>
	<'.trim('table '.$tableParams).'>';
		
	for($i=0; $i<$n; $i++)
		{
		$sTables .= '<tr>
			'.implode('',$cells[$i]).'
			</tr>';
		}
				
	$sTables .=	'</table>
	</div>';
	return $sTables;
	}




More information about the TYPO3-dev mailing list