[TYPO3-english] odd / even classes for every second record
Tyler Kraft
tyler.kraft at netefficiency.co.uk
Tue Jan 12 12:35:11 CET 2010
Hi
Just and idea for another means of doing it -as we know that all the odd
and even item will have predefined numbers you could just do this :
temp.boxenelemente = CONTENT
temp.boxenelemente {
table = tt_content
select {
where = colPos = 2
orderBy = sorting
}
renderObj < tt_content
renderObj.outerWrap = <div class="odd">|</div>
renderObj.outerWrap.override = <div class="even">|</div>
renderObj.outerWrap.override.if.value =
2,4,6,8,10,12,14,16,18,20,22,24,26,28,30
renderObj.outerWrap.override.if.isInList.data = cObj:parentRecordNumber
}
This will wrap all of the content including the back to top link and the
space before/after default frame wrapping. You could, if you really
wanted, incorporate this idea into the innerWrap for tt_content and this
it would also adjust the spacing in a nicer manner.
Ok yes Peters solution will always work, and this is much more limited
as it will only work as long as we don't have more than 31 items - but
if you really need more than that number of items then either you have
to much content on the page or you're doing some sort of list/menu
structure and you should use Peters solution
hth
Peter Russ wrote:
> --- Original Nachricht ---
> Absender: B.Wolf
> Datum: 11.01.2010 16:29:
>> Hi there.
>>
>> I'm using "insert records" to put often used boxes into the right
>> column of my site. To display them on the page I use the
>> following code:
>>
>> temp.boxenelemente = CONTENT
>> temp.boxenelemente {
>> table = tt_content
>> select {
>> where = colPos = 2
>> orderBy = sorting
>> }
>> }
>>
>> subparts.sidebar< temp.boxenelemente
>>
>>
>> Now every second box should have a different header-color, so I would
>> like to wrap the first box-element in a div with the class 'odd' and
>> the second in a div with the class 'even' - or something like that.
>> I have no clue how I could achieve this - any help is very welcome.
>>
>> Thank you very much!
>
> Register is your friend:
> Take the actual record count, modulo 2 and store it.
> Depending if the result is 1 override the the wrap.
>
> Does that help?
>
> If not here is a more complex example: (doing a m x n matrix)
>
> genericAuction=CONTENT
> genericAuction{
> table=###TBD###
> select{
> where=###TBD###
> orderBy=
> max=20
> }
> renderObj=COA
> renderObj{
> 1=LOAD_REGISTER
> 1.counter=0
> 1.counter{
> override=1
> override{
> if.isFalse.prioriCalc=1
> if.isFalse.cObject=TEXT
> if.isFalse.cObject{
> insertData=1
> value=1
> wrap=({cObj:parentRecordNumber}-1) %|
> }
> }
> }
> 1.modulo=0
> 1.modulo{
> override=1
> override{
> if.isFalse.prioriCalc=1
> if.isFalse.cObject=TEXT
> if.isFalse.cObject{
> insertData=1
> value=1
> wrap=(({cObj:currentRecordTotal} -
> ({cObj:parentRecordNumber}-1)) / |)%2
> }
> }
> }
>
> 10=COA
> 10{
> stdWrap.outerWrap.cObject=COA
> stdWrap.outerWrap.cObject{
> 10=COA
> 10{
> stdWrap.outerWrap=<div class="|">
> 10=COA
> 10{
> 10=TEXT
> 10{
> value=item
> outerWrap=|-regular
> outerWrap.override.cObject=TEXT
> outerWrap.override.cObject{
> if.isTrue.data=register:counter
> value=|-break
> }
> }
> stdWrap.outerWrap=|-fx even
> stdWrap.outerWrap.override.cObject=TEXT
> stdWrap.outerWrap.override.cObject{
> if.isTrue.data=register:modulo
> value=|-fx odd-cell
> }
> }
> }
> 20=TEXT
> 20{
> value=|
> wrap=|</div>
> }
> }
> 10=TEXT
> 10{
> value=Hier kommt der Inhalt rein
> }
> }
> }
> }
>
More information about the TYPO3-english
mailing list