[TYPO3-mvc] Howto check if object with a specific uid is related to an object (m:n relation)?

Tim Schoch | GSTALTIG tim.schoch at gstaltig.ch
Thu Nov 17 07:49:30 CET 2011


Hi
If you wan't to handle multiple types, you could set the uid of the desired types in typoscript and pass them to a custom view helper. 
The call could look something like this:
<ext:hasType download="{download}" types="{settings.types}" />
Inside you loop the downloadTypes and check the uids against the passed types.
The VH itself could extend the if viewhelper if you need the if/then/else parts or just return a string/bool as henjo suggested.
Tim
  _____  

From: Roland [mailto:most.wanted at gmx.at]
To: typo3-project-typo3v4mvc at lists.typo3.org
Sent: Wed, 16 Nov 2011 21:52:21 +0100
Subject: Re: [TYPO3-mvc] Howto check if object with a specific uid is related to an object (m:n relation)?

hey,
  
  > what you do here is extending your object model with a property of
  > something it can reach already. To me that doesn't sound too clean ;-)
  
  ok, this sounds really not that clean. ;-)
  
  > Since you already have the type related to your Download object, I would go
  > for writing a viewhelper that returns true (or the string
  > class="important") after giving it the objects of the download types and
  > checking from within your viewhelper if it exists.
  
  aah, i see. i have to give the objects to a viewhelper and get the needed
  infotmation return. great!
  
  > Thinking DDD: do you really need to have a m:n relationship from download
  > to type? Can one download really have multiple types? I might not
  > understand what you are trying to achieve, but if it can't, make it a n:1
  > relationship (types can have multiple downloads, but a download can only
  > have one type).
  
  this is something you can discuss. i in the beginning designed n:1, but
  wanted to be a little bit more flexible... i have got this feeling, that
  there will be at least one further type that can then be added to a
  download in addition...
  
  > Then from within your downloads controller you can simply say
  > {f:if(condition:download.downloadType.type=1, then:'class=Important')} ...
  
  yes, this would then be less complicated.
  
  kind regards.
  
  roland
  _______________________________________________
  TYPO3-project-typo3v4mvc mailing list
  TYPO3-project-typo3v4mvc at lists.typo3.org
  http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc
    


More information about the TYPO3-project-typo3v4mvc mailing list