Documentation

Light-weight, fast, simple and powerful!
Share This
Translations of this page?:

DavidCOG's Stuff

Code Snippets

Display all children of this page:

<ul>
<?php foreach ($this->children() as $child): ?>
<li><?php echo $child->link($child->title, (url_start_with($child->url) ? ' class="current"': null)); ?></li>
<?php endforeach; ?>
</ul>

Display all children of specified page:

<ul>
<?php foreach($this->find('about-us')->children() as $menu): ?>
<li><?php echo $menu->link(); ?></li>
<?php endforeach; ?>
</ul>

Side menu which appears only when parent has children:

<?php foreach($this->find('/')->children() as $topPage): ?>
<?php if (in_array($topPage->slug, explode('/', $this->url))) { $thisPage = $topPage->slug; } ?>
<?php endforeach; ?>

<?php
   if (count($this->find($thisPage)->children()) > 0  && $this->level() > 0) {

echo '<ul class="sidemenu">';

     foreach($this->find($thisPage)->children() as $menu): ?>
       <li<?php echo (url_start_with($menu->url)) ? ' class="current"': null; ?>><?php echo $menu->link(); ?></li>
     <?php endforeach;

echo '</ul>';

   }
?>

call from layout with:

<?php $this->includeSnippet('sidemenu'); ?>
 
user/davidcog.txt · Last modified: 2011-09-12 00:46 (external edit)
 
Except where otherwise noted, content on this wiki is licensed under the following license:GNU Free Documentation License 1.2
Copyright 2010 wolfcms.org / design by yello studio / Wolf CMS Inside