Skip to content

Instantly share code, notes, and snippets.

@fritzmg
Created November 26, 2015 14:26
Show Gist options
  • Save fritzmg/81266c77526262fbbf0a to your computer and use it in GitHub Desktop.
Save fritzmg/81266c77526262fbbf0a to your computer and use it in GitHub Desktop.
nav_newscategories template for the Contao news_categories extension which also takes the jumpTo page into account
<ul class="<?php echo $this->level; ?>">
<?php foreach ($this->items as $item): ?>
<?php
// build link to jumpTo page
if( $item['jumpTo'] )
{
$objJump = \PageModel::findByPk( $item['jumpTo'] );
if( $objJump !== null )
$item['href'] = $this->generateFrontendUrl( $objJump->row() );
}
?>
<?php if ($item['isActive']): ?>
<li class="<?php echo $item['class']; ?>"><span class="<?php echo $item['class']; ?>"><?php echo $item['link']; ?></span><?php if ($this->showQuantity): ?> <span class="quantity">(<?php echo $item['quantity']; ?>)</span><?php endif; ?><?php echo $item['subitems']; ?></li>
<?php else: ?>
<li class="<?php echo $item['class']; ?>"><a href="<?php echo $item['href']; ?>" class="<?php echo $item['class']; ?>" title="<?php echo $item['linkTitle']; ?>"><?php echo $item['link']; ?><?php if ($this->showQuantity): ?> <span class="quantity">(<?php echo $item['quantity']; ?>)</span><?php endif; ?></a><?php echo $item['subitems']; ?></li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment