[TYPO3] (enhanced) Split menu with variable number of items in half

Tyler Kraft headhunterxiii at yahoo.ca
Thu Jun 28 11:36:15 CEST 2007


Hi

I did something similar and posted it on typo3wizard, but I think yours 
is perhaps the better one - would you mind putting it up here:

http://www.typo3wizard.com/en/content-comments.html?no_cache=1&tx_rfcontentcomments_pi1%5Bcontentuid%5D=365

Tyler



Francois Suter wrote:
> Hi all,
> 
> The following menu has been for a while an example of how to do a 
> 2-column menu and I implemented it today at a client's. It works fine 
> but I realised it has a small drawback: empty <a> tags are generated for 
> all the links that are in the other half of the menu. This comes from 
> the fact that the "if" condition is applied to the cObject of the 
> stdWrap, rather than being applied to the stdWrap itself... (continued 
> below)
> 
>> lib.splitmenu = COA
>> lib.splitmenu {
>>
>>   10 = HMENU
>>   10.special = directory
>>   10.special.value = 1
>>   10.1 = TMENU
>>   10.1 {
>>     wrap = <div>1st half of menu items<br>|</div>
>>     NO {
>>       stdWrap.cObject = COA
>>       stdWrap.cObject {
>>         10 = TEXT
>>         10.field = title
>>         if.value.data = register:count_HMENU_MENUOBJ
>>         if.negate = 1
>>         if.isLessThan.prioriCalc=1
>>         if.isLessThan.cObject=TEXT
>>         if.isLessThan.cObject.insertData=1
>>         if.isLessThan.cObject.value = ({register:count_menuItems}+1)/2
>>         wrap = |<br>
>>       }
>>     }
>>     ACT < .NO
>>     ACT = 1
>>     ACT.stdWrap.cObject.10.wrap = <strong>|</strong>
>>   }
>>   20 < .10
>>   20.1.wrap = <div>2nd half of menu items<br>|</div>
>>   20.1.NO.stdWrap.cObject.if.negate >
>> }
> 
> So I tried to move the "if" up to apply it directly to the stdWrap. I 
> also applied the same condition to the allStdWrap so that empty wraps 
> would not be generated. And this produces a perfectly clean HTML 
> structure with no empty or unnecessary tags. So here's the code in case 
> it can be of use to someone else.
> 
> lib.splitmenu = COA
> lib.splitmenu {
>     10 = HMENU
>     10 {
>         special = directory
>         special.value = 1
>         1 = TMENU
>         1 {
>             wrap = <div>1st half of menu items<br />|</div>
>             NO {
>                 allStdWrap {
>                     wrap = |<br />
>                     if {
>                         value.data = register:count_HMENU_MENUOBJ
>                         negate = 1
>                         isLessThan {
>                             prioriCalc = 1
>                             cObject = TEXT
>                             cObject.insertData = 1
>                             cObject.value = ({register:count_menuItems} 
> + 1) / 2
>                         }
>                     }
>                 }
>                 stdWrap.if < .allStdWrap.if
>             }
>             ACT < .NO
>             ACT = 1
>             ACT.stdWrap.wrap = <strong>|</strong>
>         }
>     }
>     20 < .10
>     20.1.wrap = <div>2nd half of menu items<br>|</div>
>     20.1.NO.stdWrap.if.negate >
>     20.1.NO.allStdWrap.if.negate >
>     20.1.ACT.stdWrap.if.negate >
>     20.1.ACT.allStdWrap.if.negate >
> }
> 
> Cheers
> 
> François Suter
> Directeur technique
> ------------------------------------------------------------------------------------------------------------------------------------- 
> 
> Cobweb Development Sàrl
> www.cobweb.ch
> ------------------------------------------------------------------------------------------------------------------------------------- 
> 
> 
> 


More information about the TYPO3-english mailing list