Categories > TinyButStrong general >

blk.key appears even if block is empty

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Col
Date: 2005-02-04
Time: 01:18

blk.key appears even if block is empty

Hi, Here's what I'm trying to do. I have a side menu which, when a link is clicked, displays a submenu. At that time any previously opened submenus will be closed.

PHP code: $menu_item is a global and is set via url rewritting
if ($menu_item == "reports") {
    $reports = array("Report 1" => 'report1.php',
    "Report 2" => 'report2.php',
    "Report 3" => 'report3.php',
    $tbs->MergeBlock('reportsblk', $reports);
}

if ($menu_item == "maintain") {
    $maintain = array("Maintain 1" => 'maintain1.php',
    "Maintain 2" => 'maintain2.php',
    "Maintain 3" => 'maintain3.php');   
    $tbs->MergeBlock('maintainblk', $maintain);
}

$tbs->Show();

html code:
<a href="[var..script_name]?which_button=reports" target="_self">
<img src="b_reports.gif" width="116" height="25" alt="Reports" no border>
</a>
<a href="[reportsblk.val;block=a;when [var.menu_item]=='reports']" target="main">[reportsblk.key]<br>
</a>
<a href="[var..script_name]?which_button=maintain" target="_self">
<img src="b_maintain.gif" width="116" height="25" alt="Maintain" no border>
</a>
<a href="[maintainblk.val;block=a;when [var.menu_item]=='maintain']" target="main">[maintainblk.key]<br>
</a>

This nearly works except that [reportsblk.key] and [maintainblk.key] appear under their respective buttons when menu_item=''. They do show the appropriate submenu when the respective button is clicked but the other submunu (the one which isn't supposed to appear) still shows the tbs blk.key tag. If tried the isempty='' parameter but that leaves a space under each main menu item. Does that all make sense? Any help appreciated.

BTW, Skrol29, this template engine totally rocks (despite thte fact that it's hard to get my small brain around it <g>). Thanks for making it available.
By: Skrol29
Date: 2005-02-04
Time: 01:43

Re: blk.key appears even if block is empty

Hi Col,

The behavior you've got is normal.
First, parameter 'when' works only for conditional block [onload] or [onshow]. So they are totally ignored in your case.

The second thing is that you simply don't merge a block when the menu is not selected. But you shoud. Just merge it with an empty array in order to delete the block definition.
Php:
$reports = $array();
if ($menu_item == "reports") {
  $reports['Report 1'] = 'report1.php',
  $reports['Report 2'] = 'report2.php',
  $reports['Report 3'] = 'report3.php',
}
$tbs->MergeBlock('reportsblk', $reports);

$maintain = array();
if ($menu_item == "maintain") {
  $maintain['Maintain 1'] = 'maintain1.php',
  $maintain['Maintain 2'] = 'maintain3.php',
  $maintain['Maintain 3'] = 'maintain3.php',
}
$tbs->MergeBlock('maintainblk', $maintain);

Enjoy,
By: Col
Date: 2005-02-04
Time: 02:24

Re: blk.key appears even if block is empty

LOL . . . and my ability to make simple things complicated lives on. Thanks for the solution.