By: Antonio Agostinho
Date: 2013-03-31
Time: 21:56
|
Another Block+Subblock and 2 different arrays question
Hi guys, I guess I'm stuck. I think similar questions have been discussed before, but none of them have have exactly the points that I'm looking for.
I'm trying to merge two different arrays as block and subblock.
I have the following arrays , which are 'connected' each other by the key "catp1":
ArrayA (print_r):
Array ( [0] => Array ( [level] => 1 [catp1] => Dispositivos Móveis [num] => 19 ) [1] => Array ( [level] => 1 [catp1] => Laptops [num] => 3 ) [2] => Array ( [level] => 1 [catp1] => Tablets [num] => 1 ) )
ArrayB (print_r):
Array ( [0] => Array ( [level] => 2 [catp1] => Dispositivos Móveis [cat] => Tablets [num] => 19 ) [1] => Array ( [level] => 2 [catp1] => Laptops [cat] => Large [num] => 1 ) [2] => Array ( [level] => 2 [catp1] => Laptops [cat] => Medium [num] => 1 ) [3] => Array ( [level] => 2 [catp1] => Laptops [cat] => Small [num] => 1 ) [4] => Array ( [level] => 2 [catp1] => Tablets [cat] => Small [num] => 1 ) )
Using some stuff got from this forum:
$TBS->MergeBlock('main','array',$ArrayA);
$TBS->MergeBlock('sub','array','ArrayB[%p1%]');
And on HTML side:
<table border="1">
<tr>
<td>[main.catp1;block=tr;]
<table border="1">
<tr>
<td>
[sub.cat;block=tr;p1=[main.catp1];]
</td>
</tr>
</table>
</td>
</tr>
</table>
Unfortunately the results I have are not the ones I expected. It just outputs data from "main" and seems to completely ignore the data on the "sub" block:
Dispositivos Móveis
Laptops
Tablets
Wouldn't it output the following results?
Dispositivos Móveis
Tablets
Laptops
Large
Medium
Small
Tablets
Small
Anyone can help me out?
|
By: Skrol29
Date: 2013-04-01
Time: 00:26
|
Re: Another Block+Subblock and 2 different arrays question
Hi Antonio,
It doesn't work because [main.catp1] has values such as "Dispositivos Móveis", "Laptops", ... which are not keys of $ArrayB;
I don't think you can do the expected result with sub-template and the structure of $ArrayB : there is no sub-records under a key known by $ ArrayA.
Nevertheless, the structure of $ArrayB enables you to produce the result using a header section. See parameter "headergrp".
|