[TYPO3-mvc] HowTo handle files in .csv list

Bastian Waidelich bastian at typo3.org
Tue Feb 8 15:48:49 CET 2011


Franz Koch wrote:

Hi,

>> What should I do?
>> - create a ViewHelper that solves this
>> - fiddel the model and change the field with it's setters() and
>> getters()? (currently it is just string)
>> - fiddel the model and add(!) proper helper methods

> for me it depends on how I have to interact with this property. For some
> cases I add the needed logic to the default getters/setters for that
> property. For cases where I also need the original value I add a pair of
> assisting getters/setters.

The latter is what I'd suggest as well:
create a wrapper getter (and optionally setter) that can handle arrays:

/**
  * @return array
  **/
public function getFileArray() {
	return t3lib_div::trimExplode(',', $this->file);
}

you can access this in fluid like
<f:for each="{myObject.fileArray}" as="filename">
  {filename}
</f:for>


Chances are, that you need this in other places too so I'd prefer this 
solution to an explode viewhelper.

Best,
Bastian



More information about the TYPO3-project-typo3v4mvc mailing list