<div class="section index">
    <div class="categories">
        <?php foreach ($categories as $c) : ?>
            <div class="item">
                <p>
                   <?php $path = rtrim(category::get_path($c['id']), '/'); ?>
                   <a class="title" href="product/index/<?php echo htmlspecialchars($path); ?>"><?php echo htmlspecialchars($c['name']); ?></a><br />
                    <?php if ($image = category::get_image($c['id'])) : ?>
                        <a class="image" href="product/index/<?php echo htmlspecialchars($path); ?>"><img src="<?php echo htmlspecialchars(category::get_image_url($c['id'], $image, 140, 140)); ?>" /></a>
                    <?php endif; ?>
                </p>
            </div>
        <?php endforeach; ?>
    </div>
    <div class="products">
        <?php foreach ($products as $p) : ?>
            <div class="item">
                <p>
                   <?php $path = rtrim(category::get_path($p['category_id']), '/') . '/' . $p['path']; ?>
                   <a class="title" href="product/view/<?php echo htmlspecialchars($path); ?>"><?php echo htmlspecialchars($p['name']); ?></a><br />
                    <?php if ($image = product::get_image($p['id'])) : ?>
                        <a class="image" href="product/view/<?php echo htmlspecialchars($path); ?>"><img src="<?php echo htmlspecialchars(product::get_image_url($p['id'], $image, 140, 140)); ?>" /></a>
                    <?php endif; ?>
                </p>
            </div>
        <?php endforeach; ?>
    </div>
</div>