Skip to content
This repository has been archived by the owner on Jan 14, 2019. It is now read-only.

Commit

Permalink
Added exclude functionality to filelist.php
Browse files Browse the repository at this point in the history
  • Loading branch information
markusgiesen committed May 15, 2013
1 parent 9bed279 commit 407178a
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions snippets/filelist/filelist.php
Expand Up @@ -3,6 +3,7 @@
// set some defaults
if(!isset($sort)) $sort = 'filename';
if(!isset($direction)) $direction = 'desc';
if(!isset($exclude)) $exclude = array('md','mdown','txt');

// get the list of files for this page
$files = $page->files();
Expand All @@ -13,9 +14,20 @@
// sort the list
$files = $files->sortBy($sort, $direction);

// when excluding files, the UL will still be returned if there are no files to show
foreach($files as $file):
if(in_array($file->extension(),$exclude)):
unset($files->_[$file->filename]);
endif;
endforeach;

if(count($files->_)>0):
?>

<ul class="filelist">
<?php foreach($files as $file): ?>
<li><a href="<?php echo $file->url() ?>"><?php echo html($file->filename()) ?></a></li>
<?php endforeach ?>
</ul>
<?php endforeach; ?>
</ul>

<?php endif; ?>

0 comments on commit 407178a

Please sign in to comment.