dimanche 28 juin 2015

How to group the codes correctly

currently I have this set of codes. I have created an array to produce only one title (parent folder) for each group.

$already_output = array();
foreach ($it as $fileinfo) {

if ($fileinfo->isDir()) {
 $parent = $fileinfo->getFilename();
} 
    elseif ($fileinfo->isFile()) {

    $link  = str_replace('/NiamsDsmbFiles/Monitoring Committee Materials/', "http://ift.tt/1drcmf5", $parentFolderNameOfFile);


        if (!in_array($parent, $already_output)) {
            echo "Parent folder: " . $parent . ""; 
            $link =  $link . '/' . $parent . '/' . $fileinfo->getFilename();
            $already_output[] = $parent;
             else {echo '<li><a href="' . $link . '">';
            printf($fileinfo->getFilename(), $it->getSubPath(), $fileinfo->getFilename());
            echo '</a>';
        echo '</li>';                              }}



} 

}

This is displaying like this below:

Parent Folder 1: abcdef
name_of_the_pdf.pdf

Parent Folder 2: abcdef
name_of_the_pdf2.pdf
name_of_the_pdf3.pdf
name_of_the_pdf4.pdf

Parent Folder 3: abcdef
name_of_the_pdf5.pdf
name_of_the_pdf6.pdf
name_of_the_pdf7.pdf

I would like to know how I can group each parent folder together so I can make it collapsible using jquery accordion. When I apply jquery accordion to this, it groups only the first attachment to each parent folder like this.

+Parent Folder 1: abcedf
(Inside) name_of_the_pdf.pdf

Parent Folder 2: abcdef
(Inside) name_of_the_pdf2.pdf
name_of_the_pdf3.pdf
name_of_the_pdf4.pdf

Parent Folder 3: abcdef
(Inside)name_of_the_pdf5.pdf
name_of_the_pdf6.pdf
name_of_the_pdf7.pdf

Could you assist me so that all of the attachments are grouped under each parent folder please?

Thank you so much in advance.

Aucun commentaire:

Enregistrer un commentaire