<?php global $pagelist, $page_info; ?>

<?php if($module_settings['list-pages']['show sort headlines'] == 0) { ?>
<div class="container">
    <ol>
<?php } ?>

<?php foreach($pagelist as $category_entry) { ?>
	<?php if($module_settings['list-pages']['show sort headlines'] == 1) { ?>
    <div class="cat-<?php echo $category_entry['id']; ?> container">
    	<h4 class="cat-<?php echo $category_entry['id']; ?> <?php if($page_info->category == $category_entry['title']) echo 'active'; ?>" title="<?php echo $category_entry['description']; ?>">
    		<a href="<?php echo $category_entry['first page']; ?>"><?php echo $category_entry['title']; ?></a>
    	</h4><br>
	<?php } ?>
    
	<?php if($module_settings['list-pages']['show sort headlines'] == 1 && count($category_entry['pages']) > 0) { ?>
    		<ol class="cat-<?php echo $category_entry['id']; ?> <?php if($page_info->category == $category_entry['title']) echo 'active'; ?>">
    <?php } ?>
	
		<?php foreach($category_entry['pages'] as $page_entry) { ?>
	   		<li class="<?php if($page_entry->alias == strval($page_info->alias)) echo 'active'; ?>">
	   			<a title="<?php echo $page_entry->description; ?>" href="<?php echo $page_entry->href; ?>"><?php echo $page_entry->title; ?></a>
	   		</li>
		<?php } ?>
	
	<?php if($module_settings['list-pages']['show sort headlines'] == 1 && count($category_entry['pages']) > 0) { ?>
		</ol>
    <?php } ?>

	<?php if($module_settings['list-pages']['show sort headlines'] == 1) { ?>
	</div>
	<?php } ?>
<?php } ?>
	
<?php if($module_settings['list-pages']['show sort headlines'] == 0) { ?>
	</ol>
</div>
<?php } ?>