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