[TYPO3-english] ST template checkboxes

Sergey Alexandrov serg at alexandrov.us
Wed Dec 28 17:39:59 CET 2011


Thanks, Jigal

I thought about something like that, but it will not work:

See, if BOTH options selected, the "options" field will have value of 3 
(0011 binary) and "First option" will not be rendered, only the second.
And so on: if 3 first boxes checked, "options" field will have value of 
8 (0111). In his case neither first nor second options will be rendered :(

There is an "prioriCalc" stdWrap property 
(http://typo3.org/documentation/document-library/references/doc_core_tsref/4.1.0/view/5/1/)
and it does some simple math calculations except bitwise operators :)

Will patch the core then or just write userFunc ....

Interesting, having such data structure in the core but no render TS 
function ....

Thank you,
Sergey

On 12/28/2011 10:51 PM, Jigal van Hemert wrote:
> Hi,
>
> On 28-12-2011 10:58, Sergey Alexandrov wrote:
>> I have an 'options' field in the database, which is a set of check-boxes
>> I'm trying to display some message(s) depending on checked values with
>> typoscript, but ... couldn't find if I can use bitwise operators in
>> typoscript.
>> I have no problem with a single check-box, but set of boxes is actually
>> is bit set ... any ideas?
>
> The quickest solution I could think of is two checks in your if.
> For each bit you could check if it's greater or equal to the value the 
> bit represents but smaller than the value the next bit represents:
>
> bit 0: >= 1 AND < 2
> bit 1: >= 2 AND < 4
> bit 2: >= 4 AND < 8
> bit 3: >= 8 AND < 16
> ....
>
> Because "if" doesn't know 'greater than or equal' you can use 
> isGreaterThan and compare to next bit value minus one:
>
> 10 = TEXT
> 10 {
>   value = First option
>   if {
>     value.field = options
>     isGreaterThan = 0  # >= 1
>     isLessThan = 2     # < 2
>   }
> }
> 20 = TEXT
> 20 {
>   value = Second option
>   if {
>     value.field = options
>     isGreaterThan = 1  # >= 2
>     isLessThan = 4     # < 4
>   }
> }
> (code not tested)
>


More information about the TYPO3-english mailing list