Categories > TinyButStrong general >

Having trouble with the serial parameter.

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: John
Date: 2011-05-24
Time: 03:15

Having trouble with the serial parameter.

I've been using the serial keyword in one of my templates to dynamically create a table of products. 

$product_pages = new ProductsList();
$TBS->MergeBlock('product_links', $product_pages->mProduct_links);
$TBS->MergeBlock('product_thumbs', $product_pages->mProduct_thumbs);

$TBS->MergeBlock('product_size', $product_pages->mProduct_size);
$TBS->MergeBlock('product_color', $product_pages->mProduct_color);

Using the php code above I've been able to successfully populate the following template code:
<a href="[product_links_1.val;block=td;htmlconv=no][product_links;block=tr;serial]">[product_list_1.name;block=td][product_list;block=tr;serial]</a>

<a href="[product_links_1.val;block=td;htmlconv=no]"><img src="[product_thumbs_1.val;block=td][product_thumbs;block=tr;serial]" alt="[product_list_1.name]"></a>

. . .

<a href="[product_links_2.val;block=td;htmlconv=no]">[product_list_2.name;block=td]</a>

<a href="[product_links_2.val;block=td;htmlconv=no]"><img src="[product_thumbs_2.val;block=td]" alt="[product_list_2.name]"></a>

. . .

<a href="[product_links_0.val;block=td;htmlconv=no]">[product_list_0.name;block=td]</a>

<a href="[product_links_0.val;block=td;htmlconv=no]"><img src="[product_thumbs_0.val;block=td]" alt="[product_list_0.name]"></a>


I have been unsuccessful in dynamically populating the following template code:
<select name="attr_color" id="attr_color">
<option value="">Select one</option>
<option value="[product_color_1.attribute_value_id;block=option][product_color;block=option;serial]">[product_color.attribute_value]</option>               
</select>

<label for="attr_size">Size:</label>
<select name="attr_size" id="attr_size">
<option value="">Select one</option>
<option value ="[product_size_1.attribute_value_id;block=option][product_size;block=option;serial]">[product_size_1.attribute_value]</option>
</select>

. . .

<label for="attr_color2">Color:</label>
<select name="attr_color2" id="attr_color2">
<option value="">Select one</option>
<option value="[product_color_2.attribute_value_id;block=option]">[product_attributes.attribute_value]</option>               
</select>

<label for="attr_size2">Size:</label>
<select name="attr_size2" id="attr_size2">
<option value="">Select one</option>
<option value ="[product_size_2.attribute_value_id]">[product_size_2.attribute_value]</option>
</select>

. . .

<label for="attr_color0">Color:</label>
<select name="attr_color0" id="attr_color0">
<option value="">Select one</option>
<option value="[product_color_0.attribute_value_id;block=option]">[product_color_0.attribute_value]</option>               
</select>

<label for="attr_size0">Size:</label>
<select name="attr_size0" id="attr_size0">
<option value="">Select one</option>
<option value ="[product_size_0.attribute_value_id]">[product_size_0.attribute_value]</option>
</select>

I am able to dynamically populate color and size options for the first cell of my table of products. The second cells option tags are populated as
[product_size_2.attribute_value]
and
[product_color_2.attribute_value]
rather than actual values.
By: Skrol29
Date: 2011-05-24
Time: 23:48

Re: Having trouble with the serial parameter.

Hi John,

When you use parameter "serial", the TBS field which as the "serial" parameter must surround the other sub-block named with "_1", "_2", ...
Only "_0" may be in another main block.

But I don't see what you trying to have with your second template snippet.
By: John
Date: 2011-05-25
Time: 03:18

Re: Having trouble with the serial parameter.

I guess I haven't explained my self clearly. 

I'm not sure what you are saying when you say "When you use parameter "serial", the TBS field which as the "serial" parameter must surround the other sub-block named with "_1", "_2", ...
Only "_0" may be in another main block."

The following snippets of code have yielded results which work properly for me:
[product_links_1.val;block=td;htmlconv=no]
[product_links_2.val;block=td;htmlconv=no]
[product_links_0.val;block=td;htmlconv=no]

Using serial with _1, _2 and _0 has allowed me to create a 4 celled table with multiple pages. Using _0 has made it possible to have a page with less than 4 cells in a table on a page.

The following code snippet has been problematic for me:
<select name="attr_color" id="attr_color">
<option value="">Select one</option>
<option value="[product_color_1.attribute_value_id;block=option][product_color;block=option;serial]">[product_color.attribute_value]</option>   
</select>

<label for="attr_size">Size:</label>
<select name="attr_size" id="attr_size">
<option value="">Select one</option>
<option value ="[product_size_1.attribute_value_id;block=option][product_size;block=option;serial]">[product_size_1.attribute_value]</option>
</select>

<label for="attr_color2">Color:</label>
<select name="attr_color2" id="attr_color2">
<option value="">Select one</option>
<option value="[product_color_2.attribute_value_id;block=option]">[product_attributes.attribute_value]</option>   
</select>

<label for="attr_size2">Size:</label>
<select name="attr_size2" id="attr_size2">
<option value="">Select one</option>
<option value ="[product_size_2.attribute_value_id]">[product_size_2.attribute_value]</option>
</select>

This code:
[product_color_1.attribute_value_id;block=option]
creates the following html markup, as it should:
<option value="6">White</option>
<option value="7">Black</option>
<option value="8">Red</option>
<option value="9">Orange</option>
<option value="10">Yellow</option>
<option value="11">Green</option>
<option value="12">Blue</option>
<option value="13">Indigo</option>
<option value="14">Purple</option>

For some reason this code:
[product_color_2.attribute_value_id;block=option]
yields an option tag with the value [product_color_2.attribute_value_id;block=option] instead of a corresponding list of option tags.