Welcome Guest, Not a member yet? Register   Sign In
directory_map -how to show dirs only
#1

[eluser]Unknown[/eluser]
Hi All,

I have a problem, I don't know how to show only a list of folders without files with directory_map function in directory helper?

I use a modified function available at: http://ellislab.com/forums/viewreply/392035/

Code:
if (! function_exists('directory_map'))
{
    function directory_map($source_dir, $top_level_only = FALSE)
    {    
        if ($fp = @opendir($source_dir))
        {
            $filedata = array();
            while (FALSE !== ($file = readdir($fp)))
            {
                if (@is_dir($source_dir.$file) && substr($file, 0, 1) != '.' AND $top_level_only == FALSE)
                {
                    $temp_array = array();
                
                    $temp_array = directory_map($source_dir.$file."/");
                
                    $filedata[$source_dir.$file] = $temp_array; //$k => directory path; $v => directory files && sub-directories
                    uksort($filedata[$source_dir.$file], 'mysort');//this will always be an array, so sort it here!
                }
                elseif (substr($file, 0, 1) != ".")
                {
                    $filedata[$source_dir.$file] = $source_dir.$file; //$k => file path; $v => file path
                }
            }
            return $filedata;
        }
    }
}




Theme © iAndrew 2016 - Forum software by © MyBB