Zum Inhalt springen

LINK Syntax im String parsen

Erstellt am 6. November 2008 · 1 Antwort · letzte Antwort am 9. November 2008

Tags: Frage

einpraegsam.​net ·

So, habe etwas herumprobiert - wer auch die T3 Link syntax ohne p-Tags (!) in seiner Extension nutzen will:

$str = '<link 1>bla</link>';
$parseFunc = $GLOBALS['TSFE']->tmpl->setup['lib.']['parseFunc_RTE.'];
$parseFunc['nonTypoTagStdWrap.']['encapsLines.']['removeWrapping'] = 1;

return $this->cObj->parseFunc($str, $parseFunc);
Stoneage ·

Ich habe auch mal etwas mit dem TS-Parser rumgespielt. Dieser Code produziert eine Select-Box wie in https://docs.typo3.org/m/typo3/reference-tca/main/en-us/Index.html.

 // Typoscript setup
$setup[] = '10 = TEXT
10.label = This is a label
10.config.type = select';
			
  // Getting a category-tree
$top = t3lib_div::makeInstance("t3lib_treeView");
$top->init();
$top->table = $PA['fieldConf']['config']['treeAltTable'];
$top->parentField = 'parent_uid';
$top->treeName = preg_replace('/_/','',$PA['fieldConf']['config']['treeAltTable']);
$top->expandAll = 0;
$tree = $top->getTree($PA['fieldConf']['config']['treeAltUid']);

 // Error Handling				
if (!sizeOf($tree)) {
 die("no Top-Levels");
}

 // Looping through the category-tree and building Typoscript syntax		
$c=0;
foreach ($top->tree as $k => $v) {
 $setup[] = "10.config.items.$c.0 = " .$v['row']['title'];			 
 $setup[] = "10.config.items.$c.1 = " .$v['row']['uid'];
 $c++;
}

 // more Typoscript configuring properly the selector box 				
$setup[] = '10.default = 0';
$setup[] = '10.itemFormElName = data['.$PA['fieldConf']['config']['treeAltTree'].']['.$PA['row']['uid'].']['.$PA['fieldConf']['config']['treeAltField'].']';
$setup[] = '10.table = '.$PA['fieldConf']['config']['treeAltTree'];
$setup[] = '10.field = '.$PA['fieldConf']['config']['treeAltField'];
$setup[] = '10.fieldChangeFunc.TBE_EDITOR_fieldChanged = TBE_EDITOR.fieldChanged(\''.$PA['fieldConf']['config']['treeAltTree'].'\',\''.$PA['row']['uid'].'\',\''.$PA['fieldConf']['config']['treeAltField'].'\',\'data['.$$PA['fieldConf']['config']['treeAltTree'].']['.$PA['row']['uid'].']['.$PA['fieldConf']['config']['treeAltField'].']\');TBE_EDITOR_submitForm();return false;';
$setup[] = '10.itemFormElValue = '.$PA['row'][$PA['fieldConf']['config']['treeAltField']];
}

 // parsing of Typoscript
$this->parser = t3lib_div::makeInstance("t3lib_TSparser");
$this->parser->parse(implode(chr(10),$setup));
	
 // putting together a fake PA
$fakePA=array();
$fakePA=$this->parser->setup['10.'];
unset($fakePA['config.']);
$fakePA['fieldConf']['config']=$this->parser->setup['10.']['config.'];
unset($fakePA['fieldConf']['config']['items.']);
$fakePA['fieldConf']['config']['items']=$this->parser->setup['10.']['config.']['items.'];
$fakePA['fieldConf']['config']['maxItems']=$this->parser->setup['10.']['config.']['maxItems'];
unset($fakePA['fieldChangeFunc.']);
$fakePA['fieldChangeFunc']['TBE_EDITOR_fieldChanged']=$this->parser->setup['10.']['fieldChangeFunc.']['TBE_EDITOR_fieldChanged'];

 // building the menu
$item = $this->pObj->getSingleField_typeSelect($top->table,'Select',$PA['row'],$fakePA);

Problematisch an der ganze Sache ist, dass der Typoscript-Parser immer diesen . mit parst (deshalb auch diese ganzen unset-Befehle). D.h. ich weiß nicht genau, ob das obengenannte Beispiel auch alltagstauglich ist.