Additional characteristics of the product cycle are displayed in the sort order in the administrative part. They even have a separate template modules/shop/views/shop.view.param.php.
But it so happens that you need some particular characteristics bring in a certain place. For example, there is a characteristic "Color" and the information to us about the color you want to display in this form:
Example:
Colors:
There are two ways to select characteristic: by identifier and name.
An array of features with an identifier called – $result["names_param"]
. In this case, the code will be:
Example:
if(! empty($result["names_param"]["Color"]))
{
echo 'Color: ';
foreach($result["names_param"]["Color"]["value"] as $value)
{
echo '<img src="/img/box_';
switch($value)
{
case 'Yellow';
echo 'yellow';
break;
case 'Red';
echo 'red';
break;
case 'Green';
echo 'green';
break;
}
echo '" alt="'.$value.'">';
}
}
In the example, we were taken to the type of response "select multiple". For it is given several values, so the variable $result["names_param"]["Color"]["value"] is defined as an array. All other variables have a single value. For example, characteristics for the text "Material" will be the following code:
Example:
if(! empty($result["names_param"]["Material"]))
{
echo 'Material: '.$result["names_param"]["Material"]["value"];
}
If you want to use instead of the identifier, then turn to the array $result["ids_param"]
.
Example:
if(! empty($result["ids_param"][3]))
{
echo $result["ids_param"][3]["name"].': '.$result["ids_param"][3]["value"];
}
The above discussed cases in which characteristics an item card. In other cases, we replace $result
on $row
. To display the characteristics in the block or the list, make sure the appropriate option should be marked for it.
An example can be applied to "Ads" module.