Magento and the Toy Safety Directive

The technique is to prefix the product attributes with 'warning' so that they can be easily identified, then using the extensible design offered by Magento to modify the way the attributes are displayed, normal attributes first, followed by any warning attributes if they are appropriate.  As the European Directive is very clear with respect to the messages prescribed, it is possible to define them using Yes/No answers.  The following shows some of those attributes.

warning_tsd_01_under3 Not suitable for children under three years
warning_tsd_02_domestic_use Only for domestic use
warning_tsd_03_adult_supervision To be used under the direct supervision of an adult
etc.

The code used to render the attributes is extended from the default template as follows

app/design/frontend/default/mydesign/template/catalog/product/view/attributes.phtml

<?php
    $_helper = $this->helper('catalog/output');
    $_product = $this->getProduct();
    $_warning = false;
?>
<?php if($_additional = $this->getAdditionalData()): ?>
    <h2><?php echo $this->__('Additional Information') ?></h2>
    <table class="data-table" id="product-attribute-specs-table">
        <col width="25%" />
        <col />
        <tbody>
        <?php foreach ($_additional as $_data): ?>
        <?php if (substr($_data['code'], 0, 8) == 'warning_') {
                if ($_data['value'] == 'Yes') {
                    $_warning = true;
                }
            } else {
        ?>
            <tr>
                <th class="label"><?php echo $this->htmlEscape($this->__($_data['label'])) ?></th>
                <td class="data"><?php echo $_helper->productAttribute($_product, $_data['value'], $_data['code']) ?></td>
            </tr>
        <?php } ?>
        <?php endforeach; ?>
        </tbody>
    </table>
    <script type="text/javascript">decorateTable('product-attribute-specs-table')</script>
        <?php if ($_warning == true) { ?>
    <p>&nbsp;</p>
    <h2><?php echo $this->__('Warning') ?></h2>
    <table class="data-table" id="product-attribute-warning-table">
        <tbody>
        <?php foreach ($_additional as $_data): ?>
        <?php if (substr($_data['code'], 0, 8) == 'warning_' && $_data['value'] == 'Yes') { ?>
            <tr>
                <td class="data"><?php echo $this->htmlEscape($this->__($_data['label'])) ?></td>
            </tr>
        <?php } ?>
        <?php endforeach; ?>
        </tbody>
    </table>
    <script type="text/javascript">decorateTable('product-attribute-warning-table')</script>
        <?php } ?>
<?php endif;?>

By Alan Hicks