[Typo3-dev] Access media field via ID/name rather than position

Ingmar Schlecht ingmars at web.de
Tue Feb 17 15:44:42 CET 2004


Hi Sacha,

Sacha Vorbeck wrote:
> But when you work with more than one image, it is requiered to add the 
> same amount of images to the media field (or none) to every page as you 
> can`t address the images properly with position otherwise.
> 
> This is why I think it would be a good idea to add an ID property to the 
> levelmedia ressources.
> 
> Then you could do something like:
> import = uploads/media/
> import.field = media
> import.id = topimage
> 
> instead of
> 
> import.listNum = 0

Yes, but how would you implement the ID thing in the Backend forms?

I'd prefer a different approach. IMHO the way to go would be introducing 
a new field called "flexmedia" being a flexform field with n number of 
possible elements each having a "title", "type" and "file" field.

The "type" field could be a selector box with values like "topimage", 
"footerimage", "menuheader".

Then we'd just need a way to access values of a flexform field with stdWrap.

Perhaps there could be a stdWrap property/function called "flexPath" 
which would treat the incoming $content as FlexForm XML code and would 
extract and return the value of a certain subfield.

Pseudo TS:

import = uploads/media/
   // this returns the plain value (here: XML) of the field as usual:
import.field = flexmedia
   // and this parses the XML and returns the field "image" of the
   // element where the value of the type field equals "topimage"
import.flexPath = image[type=topimage]

Now the only thing left is the PHP code implementing it :-)

> I guess this could be done with an extension 

Yes, of course. You could easily implement it in an extension even 
without using XCLASSes (which should be avoided for some reasons).

The pseude TS from above could look like this then:

import = uploads/media/
import.postUserFunc = tx_yourextension_flexget
import.postUserFunc.field = flexmedia
import.postUserFunc.flexPath = image[type=topimage]


> but I don`t know what`s best practice in this case:

First...

> add it as an extension

then publish it and hope for a core developer to...

> add it to the source 


cheers,
Ingmar




More information about the TYPO3-dev mailing list