Categories > TinyButStrong general >

Nesting Blocks

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: c wells
Date: 2006-07-06
Time: 03:20

Nesting Blocks

I have a block for navigation like this:
[Left;block=begin]<div>blah blah</div>[Left;block=end]

Now, what I want to do is insert the sub-navigation inside that block, like:
[Left;block=begin]<div>blah blah</div>[SubLeft;block=begin]<div>sub blah</div>[SubLeft;block=end][Left;block=end]

However, when I do that the merge is not right.  I am merging SubLeft before I merge Left, but when SubLeft is non-existent (merged with 'clear') it only draws the first element of Left, not all of them.  However, when SubLeft DOES exist, it draws the subnav in the way I want it (for now).

Is there any way to create these "sub-blocks" within a block?  (Later I will make the block conditional so that the subnavigation only renders in the case where it's parent has already been selected, but for now I'm trying to pick off the low-hanging fruit).

Thanks in advance.

.cw.
By: Skrol29
Date: 2006-07-06
Time: 13:14

Re: Nesting Blocks

If you merge SubLeft before Left, then you should have several Left containing the same SubLeft. If SubLeft is cleared before, you should have only several Left. That is strange if you d'ont have this.
Did you tried to display the result of the merge juste after SubLeft is merged with 'clear' and before Left is merge? What is the template at this moment?

If you need to link SubLeft with Left, you should link sub-blocks using parameter "p1" (see Dynamic queries / sub-block in the manual :
http://www.tinybutstrong.com/manual.php#html_block_subblock
)
By: c wells
Date: 2006-07-06
Time: 14:12

Re: Nesting Blocks

I just went back in because of your debugging suggestion and noticed something.  I WAS merging SubLeft before Left when I was merging with an array, but when I was merging with 'clear' it was AFTER, which was exactly my problem.  I swapped the order, and now merge the 'clear' in first in all cases, and it works.  (Although merging Left with data followed by SubLeft with clear still did NOT give me just all of Left... only the first one...)

Now, naturally, my question is how to condition away the fact that I'm now getting them every time and not just for the top level nav that I need?  :)

I've tried:
[Left;block=begin]<div id="[Left.$]">...</div>
[SubLeft;block=begin;when [Left.$]==[var.level1Nav]]
<div id="[SubLeft.$]">...</div>[SubLeft;block=end]
[Left;block=end]

...but it doesn't seem like I've gotten the hang of using variables inside conditions.  (This would come in handy in another part of my code too).  How do you do this?
By: Skrol29
Date: 2006-07-06
Time: 14:36

Re: Nesting Blocks

Now if you actually merge SubLeft before Left, then [Left.$] is not evaluated when SubLeft is merged. So your condition is always false.

If you want to merge a bar with one item different from others, then you can try the Navigation Bar plug-in. You can customize you bar to be something else than a Navigation by page. The principle of this plug-in is to merge a block with a number of items having one different from others (the current page). It also has some first/previous/next/last managment that you don't need.

Otherwise, you cna try to do like this:
<div id="[Left.$;block=div]">
  Bla bla
  <div id="sub[SubLeft.$;block=div]">
  [Left.$;if [val]=[var.level1Nav;then '';else ' ';magnet=div]
  Bla bla
  </div>
</div>

Merge Left before SubLeft. The TBS tag with parameter magnet will destroy all Left bloc's definitions but the one corresponding to $level1Nav.