About FileSets and FileLists

Permalink
So I'm building a basic block that does the following (summary):
1) shows the list of available filesets to the user
2) displays the list of files (optionally with attributes) in the block for the page view
--
I'm fine with generating the list of available filesets with this basic code for my "add.php":
<?php
    Loader::model('file_list');
    Loader::model('file_set');
    $filesets = FileSet::getMySets($user = false)
?>
<table><tr>
<th>Select Fileset: </th><td><select name="fileSetName">
<?php  
    foreach ($filesets as $fset) {
        $fsn = $fset->getFileSetName();
        echo "<option value='$fsn'>$fsn</option>";
    }
?>
</select></tr>
<tr><th>FileSet Header Type: </th><td>


Saves, edits, and views that aspect just fine.

The next bit I'd like to add would look something like this, but I can't find the proper models/methods so far: (some pseudo-code follows)
<?php 
    Loader::model('file_list');
    Loader::model('file_set');
    $filelist = new FileList();
    if(isset($headerType)&&isset($fileSetName)) {
        $fs = FileSet::getByName($fileSetName);
       $filelist->filterByFileSet($fs);
        // if header size/type is specified
       if($headerType != '') {
            echo "<$headerType>$fileSetName</$headerType>";
        } else {
            echo "<span>---</span>"; 
            //change to whatever for the no-header condition
        }
        echo "<ul>";


Thanks!

 
Mnkras replied on at Permalink Best Answer Reply
Mnkras
take a look at this:http://pastie.org/1680066
annihilist replied on at Permalink Reply
Thanks for the post!
My error was in that I did not do one critical thing!

$files = $filelist->get();


Once I include this in my code (after $filelist->filterByFileSet($fs)),
I can loop through $files to grab each File object and do as needed!

Thanks a million.