Przeglądaj źródła

started advanced search

bach 3 lat temu
rodzic
commit
1851c84ea5

+ 26 - 7
web/modules/custom/materio_sapi/src/Form/MaterioSapiSearchForm.php

@@ -45,13 +45,32 @@ class MaterioSapiSearchForm extends FormBase {
         "v-model" => "autocomplete"
       ],
     ];
-    // $form['submit'] = [
-    //   '#type' => 'submit',
-    //   '#value' => $this->t('Search'),
-    //   '#attributes' => [
-    //     '@click.prevent' => "submit",
-    //   ]
-    // ];
+
+    $form['filters'] = [
+      '#type' => 'container'
+    ];
+
+    $query = \Drupal::entityQuery('taxonomy_term');
+    $query->condition('vid', "assisted_research");
+    $tids = $query->execute();
+    $terms = \Drupal\taxonomy\Entity\Term::loadMultiple($tids);
+
+    foreach ($terms as $tid => $term) {
+      $childs = $term->get('field_terms')->getValue();
+      $options = array($term->getName());
+      foreach ($childs as $child) {
+        $child_term = \Drupal\taxonomy\Entity\Term::load($child['target_id']);
+        $options[$child_term->id()] = $child_term->getName();
+      }
+      $form['filters']['filter-'.$tid] = array(
+        '#type' => 'select',
+        // '#title' => $term->getName(),
+        // '#multiple' => true,
+        '#options' => $options
+      );
+    }
+
+
     $form['submit'] = array(
         '#type'   => 'button',
         // '#src'    => '',//drupal_get_path('module', 'materio_search_api') . '/images/search.png',

+ 16 - 1
web/themes/custom/materiotheme/assets/dist/main.css

@@ -19751,12 +19751,27 @@ header[role="banner"] {
   header[role="banner"] #block-materiosapisearchblock {
     padding: 0; }
     header[role="banner"] #block-materiosapisearchblock #materio-sapi-search-form .form-item, header[role="banner"] #block-materiosapisearchblock #materio-sapi-search-form input.button {
-      display: inline-block; }
+      display: inline-block;
+      margin: 0; }
     header[role="banner"] #block-materiosapisearchblock #materio-sapi-search-form #edit-search {
       border: 1px #BBB solid;
       border-radius: 14px;
       padding: 0.3em;
       color: #666; }
+    header[role="banner"] #block-materiosapisearchblock #materio-sapi-search-form #edit-filters select.form-select {
+      -webkit-appearance: none;
+      -moz-appearance: none;
+      appearance: none;
+      display: inline-block;
+      background-color: #e3e3e3;
+      padding: 0;
+      border-radius: 10px;
+      font-size: 0.756em;
+      border: none; }
+      header[role="banner"] #block-materiosapisearchblock #materio-sapi-search-form #edit-filters select.form-select::-ms-expand {
+        display: none; }
+      header[role="banner"] #block-materiosapisearchblock #materio-sapi-search-form #edit-filters select.form-select option {
+        width: 5em; }
     header[role="banner"] #block-materiosapisearchblock #materio-sapi-search-form .button.form-submit {
       border: 0;
       text-indent: 50px;

+ 22 - 0
web/themes/custom/materiotheme/assets/styles/main.scss

@@ -576,6 +576,7 @@ header[role="banner"]{
     #materio-sapi-search-form{
       .form-item, input.button{
         display: inline-block;
+				margin: 0;
       }
 
       #edit-search{
@@ -585,6 +586,27 @@ header[role="banner"]{
         color:#666;
       }
 
+			#edit-filters{
+				select.form-select{
+					-webkit-appearance: none;
+				  -moz-appearance: none;
+				  appearance: none;
+					&::-ms-expand {
+						display: none;
+					}
+					display: inline-block;
+					background-color: #e3e3e3;
+					padding:0;
+					border-radius: 10px;
+					font-size: 0.756em;
+					border: none;
+					// background: url(../images/caret-down.svg) no-repeat 98% 64% #bbb;
+					option{
+						width:5em;
+					}
+				}
+			}
+
       .button.form-submit{
         border:0;
         text-indent: 50px;