Categories > TinyButStrong general >

remove css class on no data

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: OuTa-SyNc
Date: 2009-05-11
Time: 01:15

remove css class on no data

Hi All,

I have a drop-down style menu that is filled via TBS, it consists of menus and sub-menus, everything is working fine except I want to remove 'class=fly' when the menu has no submenus. see below

<ul id="nav">
<li class="top"><a href="#nogo2" id="products" class="top_link"><span class="down">[tb.catTitle;block=li]</span></a>
                   <ul class="sub">
                      <li><a href="#nogo3" class="fly">[mu.catTitle;block=li; p1=[tb.catID]]</a><ul><li><a href="#nogo19">[smu.catTitle;block=li; p1=[mu.catID]; bmagnet=ul]</a></li></ul></li>
                   </ul>
                 </li>
              </ul>

I want to be able to remove class=fly when block 'smu' has no data but I just can't seem to get it to work, I have tried bmagnet with no success.  I need to remove class=fly because it displays the menu with an arrow indicating it has a submenu.

Can anyone help?

Kind Regards,
OuTa-SyNc
By: Skrol29
Date: 2009-05-11
Time: 16:27

Re: remove css class on no data

class="[smu.*;when [val]=0;then '';else 'fly']"

TBS 3.05 has attribute features that can help to do what you describe. TBS 3.05 is available in beta version.
By: OuTa-SyNc
Date: 2009-05-11
Time: 20:03

Re: remove css class on no data

Thank you for replying, how do I optain the beta? I am currently running 3.4.0, will it not work for this version?
By: Skrol29
Date: 2009-05-12
Time: 12:00

Re: remove css class on no data

The beta is available here:
  http://groups.google.com/group/tbs-next
By: OuTa-SyNc
Date: 2009-05-12
Time: 13:43

Re: remove css class on no data

Hi Skrol29,

Thank you, I have downloaded the beta and inserted the code above but am unable to get it working, I have also inserted:

[smu.catTitle;block=li; p1=[mu.catID]; bmagnet=ul; att=class]

Still with no luck, are you able to help?
By: Skrol29
Date: 2009-05-12
Time: 15:01

Re: remove css class on no data

The code I've given above is bugged. The good one is:
<a href="#nogo3" class="[smu.#;if [val]=0;then '';else 'fly']">
And it is available for TBS current version.

By: Skrol29
Date: 2009-05-12
Time: 17:15

Re: remove css class on no data

I have to precise that the new parameter "att" (coming with the beta TBS version) will unfortunately not work in your case.

Fields that are outside their subblock will not be correctly merged if they have parameter "att" or "magnet". This is a known bug, hard to fix. It happens because "att" and "magnet" are making the field to move in a too erratic way.
By: OuTa-SyNc
Date: 2009-05-12
Time: 17:27

Re: remove css class on no data

Thank you for your help anyway, you are of course correct it doesn't work for my scenario.  Though I must admit it is a tricky one.  I'm sure I can find another way of doing it, or just leave it as it is.

Thank you for your hard work :)
By: Skrol29
Date: 2009-05-12
Time: 23:05

Re: remove css class on no data

The new snippet I've provided should work for you case.

I've also fixed the bug I've told about. The fiw will be availbale for the next beta version.
By: OuTa-SyNc
Date: 2009-05-12
Time: 23:20

Re: remove css class on no data

Oh, I didn't realise the snippet was meant to work, I thought it wouldn't work without the att function.

I did try your snippet but it didn't work. I understand what the code does but it still doesn't work, we are simply saying when the subblock is merged with no data insert 'nothing' but when data is present insert 'fly'

I don't understand why it wont work?
By: Skrol29
Date: 2009-05-13
Time: 17:31

Re: remove css class on no data

You're right it does't work neither.
It doesn't work because the [smu.#] fields placed between two sublock is merged with the data of the subblock placed before.

The only solution I see in your case is to use Javascript to change the class value.