Salmon B20 subbcode variable

The subbcode variable is used within behaviors, especially behavior 20 (B20 for short) which is the main behavior for the Salmon engine in e2c.js .

The subbcode variable allows to execute specific code upon the subbcode value.

Per default, the value will be 0 when you initiate an e2c_engine. You may reset that value to your need as per bellow:

function e2c_my_somefunction(e) {
   var he = e2c_setEngine(e).E2C.commons;
   he.subbcode = resetSubbcode(he.subbcode, 15);
   ... 
}

In the code above, we did reset subbcode to 15 but this would only work if he.subbcode was undefined, empty, or set to its default zero. The reason being in some applications where you reuse a previously created e2c_engine you may not want to overwrite it.

Therefore, if you want to force its value, you may rather do as bellow:

function e2c_my_somefunction(e) {
   var he = e2c_setEngine(e).E2C.commons;
   he.subbcode = 15;
   ... 
}

The code above would reset subbcode to 15, whatever was its previous value.

Both possibilities exist so as to cope with different applications scenarios.

At time of writing, B20 use the following subbcode values for this purposes:

- 0: default, do not process items in data
- 1: process only featuredItemsPerPage items from data
- 2: process only featuredItemsPerPage items from data
- 3: process only itemsPerPage items from data, triggers doPagination()
- 4: gallery, process itemnum (from xdata) items from data
- 5: ratings, process itemnum (from xdata) items from data
- 10: cart, process all items in data
- 15: non-cart, process all items in data
- 23: Yahoo currency converter
- 3000: Salmon admin interface, process only itemsPerPage items.

Please note that 1 and 2 values are treated the same by B20. It used to allow for distinct code execution in your code when B20 returns. As of V4, there are other mechanisms to do that.

Also, B20 will reset subbcode to 1 if subbcode is undefined. This is left for compatibility with prior versions. As of V4 this should not happen, as you are expected to use the e2c_engine.

Please keep in mind that B20 is evolving into a further generic behavior. Thus, the information above is subject to change. In doubt, please refer to B20 code in e2c.js .