[ 0 Кол-во товаров в корзине стоимостью 0,00 грн. ]  
29/03/2024 | Хитов: 11091967  
  Каталог » osCommerce » Выбор файла из списка при создании продуктов Мои данные  |  Корзина  |  Оформить заказ   
Разделы
Программы (14)
Полный список товаров
Информация
Наши контакты
Средства оплаты
Уведомление о рисках при использовании WebMoney
Прайс-лист (Excel)
Прайс-лист (HTML)
Поиск
 
Введите слово для поиска.
Расширенный поиск
Статьи
Новые статьи (0)
Все статьи (8)
Jablotron (7)
osCommerce (1)
Новинки Перейти
Улучшенный поиск товара по атрибутам
Улучшенный поиск товара по атрибутам
1,01 грн.
Выбор файла из списка при создании продуктов Выбор файла из списка при создании продуктов

Чтобы при наборе виртуального продукта не приходилось руками вбивать имя файла(вместо поля появляется select с именами всех файлов в каталоге /download):
Немного неуклюже и громоздко, но работает.

Файл:
categories.php

После:
<?php
    }
  } elseif ($action == 'new_product') {

Добавить:
   $array[]="";
    $array_rev[]="";
    $index=1;
    define('DIR_FS_DOWNLOAD', DIR_FS_CATALOG . 'download/');
    $dir_handle = @opendir(DIR_FS_DOWNLOAD) or die("Unable to open download");
    while ($file = readdir($dir_handle)) {  
    if($file == "." || $file == ".." || $file == "index.php" || $file==".htaccess") {continue;}
     else{
      $array[$file]=$index;
      $array_rev[$index]=$file;
     $index++;
         }
    }    
    closedir($dir_handle);

После:

<?php if (DOWNLOAD_ENABLED == 'true') { ?>
                <td align="center">
                   <?php
вместо
echo tep_draw_input_field('filename[' . $rows . ']',
$attributes_download['products_attributes_filename'], 'size="12" id=filename[' . $rows . ']');

Прописываем:
                   
                   echo "<select  name=" filename[" . $rows . "]"  id="filename[". $rows . "]"";
                          $option="";                      
                           $tabindex= $array[$attributes_download['products_attributes_filename']];
                           for ($i=0;$i<sizeof($array);$i++){
                           $option.="<OPTION ";
                           $option.=" VALUE="".$array_rev[$i]."">".$array_rev[$i]."</OPTION>";  
                         }
                        echo " >".$option."</select>";
                    ?></td>


Файл:
new_attributes_include.php

После:
<INPUT TYPE="HIDDEN" NAME="action" VALUE="change">
<?php
Добавляем:

    $array[]="";
    $array_rev[]="";
    $index=1;
    define('DIR_FS_DOWNLOAD', DIR_FS_CATALOG . 'download/');
    $dir_handle = @opendir(DIR_FS_DOWNLOAD) or die("Unable to open download");
    while ($file = readdir($dir_handle)) {  
    if($file == "." || $file == ".." || $file == "index.php" || $file==".htaccess") {continue;}
     else{
      $array[$file]=$index;
      $array_rev[$index]=$file;
     $index++;
         }
    }    
    closedir($dir_handle);

После:
if($dl_line['products_attributes_filename']=='')
                    {
                      $dl_line['products_attributes_maxdays']=DOWNLOAD_MAX_DAYS;
                      $dl_line['products_attributes_maxcount']=DOWNLOAD_MAX_COUNT;
                    }

Вместо:
echo "<TD class="main" align="left"><input type="text" id="" . $current_value_id . "_dlfile"  name="" . $current_value_id . "_dlfile" value="" . $dl_line['products_attributes_filename'] . "" size="10"></TD>";

Прописываем:
                        echo "<TD class="main" align="left"><select  name="" . $current_value_id . "_dlfile" value="" . $dl_line['products_attributes_filename'] . """;
                          $option="";                      
                           $tabindex= $array[$dl_line['products_attributes_filename']];
                           for ($i=0;$i<sizeof($array);$i++){
                           $option.="<OPTION ";
                            if ((strlen($dl_line['products_attributes_filename'])>0)&&($i==$tabindex)){$option.=" SELECTED ";}
                           $option.=" VALUE="".$array_rev[$i]."">".$array_rev[$i]."</OPTION>";  
                         }
                                    
                         
                        echo " >".$option."</select>";

                        echo " </TD>";

Файл:
products_attributes.php
После:
 $action = (isset($_GET['action']) ? $_GET['action'] : '');
if ($_GET['action'] == 'update_attribute'){

Добавляем:
    $array[]="";
    $array_rev[]="";
    $index=1;
    define('DIR_FS_DOWNLOAD', DIR_FS_CATALOG . 'download/');
    $dir_handle = @opendir(DIR_FS_DOWNLOAD) or die("Unable to open download");
    while ($file = readdir($dir_handle)) {  
    if($file == "." || $file == ".." || $file == "index.php" || $file==".htaccess") {continue;}
     else{
      $array[$file]=$index;
      $array_rev[$index]=$file;
     $index++;
         }
    }    
    closedir($dir_handle);
}


После:
<td colspan="8">
              <table>
                <tr>
                  <td align="right"><?php echo TABLE_HEADING_DOWNLOAD; ?>&nbsp;</td>
                  <td align="right"><?php echo TABLE_TEXT_FILENAME; ?></td>
                  <td align="right">
                  <?php
вместо:
echo tep_draw_input_field('products_attributes_filename', $products_attributes_filename, 'size="35"')

Прописываем:
echo "<select  name="products_attributes_filename" value="" . $products_attributes_filename . """;
                           $option="";
                           $tabindex= $array[$products_attributes_filename];
                           for ($i=0;$i<sizeof($array);$i++){
                           $option.="<OPTION ";
                           if ((strlen($products_attributes_filename)>0)&& ($i==$tabindex)){$option.=" SELECTED ";}
                           $option.=" VALUE="".$array_rev[$i]."">".$array_rev[$i]."</OPTION>";  
                          }
                          echo " >".$option."</select>";





После:
<td><?php echo TABLE_TEXT_FILENAME; ?></td>
                  <td>
Вместо:
echo tep_draw_input_field('products_attributes_filename', $products_attributes_filename, 'size="35"');

Прописать:
echo "<select  name="products_attributes_filename" value="" . $products_attributes_filename . """;
                           $option="";
                           $tabindex= $array[$products_attributes_filename];
                           for ($i=0;$i<sizeof($array);$i++){
                           $option.="<OPTION ";
                           if ((strlen($products_attributes_filename)>0)&& ($i==$tabindex)){$option.=" SELECTED ";}
                           $option.=" VALUE="".$array_rev[$i]."">".$array_rev[$i]."</OPTION>";  
                          }
                          echo " >".$option."</select>";




Эта статья была опубликована 08 апреля 2010 г..
Число отзывов: 0
Написать отзыв
Вход
E-Mail:
Пароль:
Регистрация
Корзина Перейти
Корзина пуста