Yoko
Yoko

Reputation: 49

Display only a directory name

I try to develop a function to display only directory start by Odoo We can have Odoo8, Odoo9, Odoo10 ... but also others directories.

How to display just Odoox directories in a dropdown

I start by that. It display all directories inside specific directory

  function  cfg_set_all_template_directory_hook_odoo_pull_down($value){

    $name = (!empty($key) ? 'configuration[' . $key . ']' : 'configuration_value');

    $template_directory = OSCOM::getConfig('dir_root', 'Shop') . 'includes/Module/Hooks/Admin/';

    $weeds = array('.', '..', '_notes', 'index.php', '.htaccess', 'README');

    $directories = array(scandir($template_directory), $weeds);
    $filename_array = array();


    foreach($directories as $value) {
      if(is_dir($template_directory.$value)) {
        $filename_array[] = array('id' => $value,
                                  'text' => $value);
      }
    }

    return HTML::selectMenu($name, $filename_array, $value);
  }

Upvotes: 2

Views: 45

Answers (1)

cmnardi
cmnardi

Reputation: 1111

inside the foreach you can put with your if this condition

foreach($directories as $value) {
     if(is_dir($template_directory.$value) && preg_match("/Odoo.+/", $value)) {
         $filename_array[] = array('id' => $value,'text' => $value);
      }
    }

Upvotes: 2

Related Questions