function renderCategory($categoryList)
{
    ?>
                <?php 
    foreach ($categoryList as $item) {
        ?>
                    <li>
                        <a class="<?php 
        echo isset($item["class"]) ? $item["class"] : '';
        ?>
" href="<?php 
        echo !isset($item["child"]) || !$item["child"] || !count($item["child"]) ? $item["url"] : "#";
        ?>
" title="<?php 
        echo $item["text"];
        ?>
">
                          <?php 
        if (isset($item["icon"])) {
            ?>
                            <span class="icon">
                                <i class="icon20 <?php 
            echo $item["icon"];
            ?>
"></i>
                            </span>
                            <?php 
        }
        ?>
                            <span class="txt"><?php 
        echo $item["text"];
        ?>
</span>
                            <?php 
        if (isset($item["child"]) && $item["child"] && count($item["child"]) > 0) {
            ?>
                                <ul class="sub">
                                    <?php 
            renderCategory($item["child"]);
            ?>
                                </ul>
                            <?php 
        }
        ?>
                        </a>
                    </li>
                <?php 
    }
}
Exemple #2
0
function renderCategory($categories, $count = 0)
{
    $space = '';
    $t = $count;
    for ($i = 0; $i < $t; $i++) {
        $space .= '&nbsp;&nbsp;&nbsp;&nbsp;';
    }
    foreach ($categories as $category) {
        if ($category->parent) {
            if ($category->id == $category->parent->id) {
                break;
            }
        }
        echo '<m-option value="' . $category->id . '">' . $space . $category->name() . '</m-option>';
        if ($category->childs) {
            renderCategory($category->childs, ++$count);
        }
    }
}
<?php

require __DIR__ . "/../vendor/autoload.php";
//connect to database
//$oDb = new PDO("sqlite:" . __DIR__ . "/../products.sqlite");
$oDb = new PDO("sqlite:" . __DIR__ . "/../products_.sqlite");
$oApp = new \Slim\Slim(array('view' => new \PHPView\PHPView(), 'templates.path' => __DIR__ . "/../views"));
$oApp->get("/", function () {
    renderCategory();
});
$oApp->get("/about", function () use($oApp) {
    $oApp->render("about_.phtml");
});
$oApp->get("/topdeals", function () use($oApp) {
    $oApp->render("topdeals_.phtml");
});
$oApp->get("/contact", function () use($oApp) {
    $oApp->render("contact_.phtml");
});
$oApp->get("/credits", function () {
    renderCredits();
});
$oApp->get("/success", function () use($oApp) {
    $oApp->render("success_.phtml");
});
$oApp->get("/failure", function () use($oApp) {
    $oApp->render("failure_.phtml");
});
$oApp->get("/products/:productID", function ($nId) {
    renderProduct($nId);
});