Branch Code - Logic, Looping and Recursive Code
As of March 2017, Branch Code is deprecated and no longer developed. Use the Twig syntax instead.
In addition to variables and tags you can also use logic and looping constructs in your code.
The foreach loops let you loop through an array of data. This is one of the most commonly used pieces of Branch Code.
An example usage would be to loop through an array of product information to build a store product list page.
For loops lets you repeatedly execute some code while a condition is true.
If / Else / ElseIf Statements
Another commonly used construct, the If/Else/ElseIf statements let you execute some code if a condition is true.
A simple but common scenario is to output some pagination if the pagination array exits.
The table row construct makes it easier to output a table with a certain number of columns in a row. It works well when the content for each column is essentially the same.
An example scenario could be to output store product data in a series of 3 column table rows for a store category page.
The tree construct allows you to recursively loop through a multidimensional array of data.
Perhaps the best example is the default code used to build a navigation menu template. In fact, that is where the original name for this language construct came from. By default a navigation menu is built with a nested unordered list. The Tree construct allows a developer to recursively build a list of data. The "tree" name comes from the idea that each sub item array is a branch off of the parent item and each sub item within the sub item array is a leaf off of that branch.