Commit 807a682c authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

Les rubriques ne s'affichent que s'il y a des liens

parent 17c6d1f5
Loading
Loading
Loading
Loading
+41 −21
Original line number Diff line number Diff line
@@ -8,44 +8,64 @@ use Laminas\Navigation\Page\Mvc;
 * @var $this      \Application\View\Renderer\PhpRenderer
 */

echo $this->tag('div', ['class' => 'callout-menu']);
$rubriques = [];

foreach ($container as $page) {
    if ($this->navigation()->accept($page)) {
        $rubrique = [
            'color'       => $page->get('color'),
            'description' => $page->get('description'),
            'icon'        => $page->get('icon'),
            'html'        => $this->navigation()->htmlify($page),
            'items'       => [],
        ];

        if ($page->hasPages()) {
            $children = (array)$page->getPages();
            uasort($children, function (Mvc $a, Mvc $b) {
                return $a->getOrder() > $b->getOrder() ? 1 : 0;
            });
            foreach ($children as $child) {
                if ($this->navigation()->accept($child)) {
                    $rubrique['items'][] = $this->navigation()->htmlify($child);
                }
            }
        }

        $rubriques[] = $rubrique;
    }
}

//var_dump($rubriques);


echo $this->tag('div', ['class' => 'callout-menu']);
foreach ($rubriques as $rubrique) {
    if (!empty($rubrique['items'])) {
        $attrs = [
            'class' => 'callout-container',
        ];
        if ($borderColor = $page->get('color')) {
        if ($borderColor = $rubrique['color']) {
            $attrs['style'] = 'background-color:' . $borderColor;
        }
        if ($description = $page->get('description')) {
        if ($description = $rubrique['description']) {
            $attrs['title'] = $description;
        }

        echo $this->tag('div', $attrs);
        echo $this->tag('div', ['class' => 'callout']);
        if ($icon = $page->get('icon')) {
        if ($icon = $rubrique['icon']) {
            echo $this->tag('span', ['class' => $icon])->open(TagViewHelper::AUTOCLOSE_FULL);
        }
        echo $this->tag('h1')->html($this->navigation()->htmlify($page));

        if ($page->hasPages()) {
        echo $this->tag('h1')->html($rubrique['html']);
        echo '<ul>';
            $children = (array)$page->getPages();
            uasort($children, function (Mvc $a, Mvc $b) {
                return $a->getOrder() > $b->getOrder() ? 1 : 0;
            });
            foreach ($children as $child) {
                if ($this->navigation()->accept($child)) {
                    echo $this->tag('li')->html(/*$child->getOrder() . ' ' .*/ $this->navigation()->htmlify($child));
                }
        foreach ($rubrique['items'] as $item) {
            echo $this->tag('li')->html($item);
        }
        echo '</ul>';
        }
        echo '</div>';
        echo '</div>';
    }
}
echo '<div style="clear: both"></div>';
echo '</div>';
 No newline at end of file