drupal-8

How to create a counter with TWIG?

落爺英雄遲暮 提交于 2020-06-29 06:42:58
问题 I have a site with Drupal 8 and I want to create a task counter with TWIG. I use views with conditions. The counter must be incremented whether the view has a result or not. Here is the code I just made : <span class="badge badge-warning task-badge-warning"> {% if drupal_view_result('boutique_page_liste_des_taches_produit_non_publie', 'block_1') is not empty %} 1 {% endif %} {% if drupal_view_result('boutique_page_liste_des_taches_role_marchand', 'block_1') is empty %} 1 {% endif %} </span>

How to create a counter with TWIG?

余生颓废 提交于 2020-06-29 06:42:11
问题 I have a site with Drupal 8 and I want to create a task counter with TWIG. I use views with conditions. The counter must be incremented whether the view has a result or not. Here is the code I just made : <span class="badge badge-warning task-badge-warning"> {% if drupal_view_result('boutique_page_liste_des_taches_produit_non_publie', 'block_1') is not empty %} 1 {% endif %} {% if drupal_view_result('boutique_page_liste_des_taches_role_marchand', 'block_1') is empty %} 1 {% endif %} </span>

Add custom class from link to drupal-modal drupal 8 with bootstrap theme

天涯浪子 提交于 2020-05-12 04:21:32
问题 In Drupal 8, with the bootstrap theme when you create a link with class and data-dialog-type attributes like the bellow code: <a class="use-ajax" data-dialog-type="modal" href="http://drupal.page/front">text </a> You will open content of the page in #drupal-modal element that has these html wrappers: <div id="drupal-modal" class="modal fade in" tabindex="-1" role="dialog" style="display: block;"> <div class="modal-dialog" role="document"> <div class="modal-content"> This structure is

Add custom class from link to drupal-modal drupal 8 with bootstrap theme

坚强是说给别人听的谎言 提交于 2020-05-12 04:20:59
问题 In Drupal 8, with the bootstrap theme when you create a link with class and data-dialog-type attributes like the bellow code: <a class="use-ajax" data-dialog-type="modal" href="http://drupal.page/front">text </a> You will open content of the page in #drupal-modal element that has these html wrappers: <div id="drupal-modal" class="modal fade in" tabindex="-1" role="dialog" style="display: block;"> <div class="modal-dialog" role="document"> <div class="modal-content"> This structure is

Add custom class from link to drupal-modal drupal 8 with bootstrap theme

故事扮演 提交于 2020-05-12 04:18:51
问题 In Drupal 8, with the bootstrap theme when you create a link with class and data-dialog-type attributes like the bellow code: <a class="use-ajax" data-dialog-type="modal" href="http://drupal.page/front">text </a> You will open content of the page in #drupal-modal element that has these html wrappers: <div id="drupal-modal" class="modal fade in" tabindex="-1" role="dialog" style="display: block;"> <div class="modal-dialog" role="document"> <div class="modal-content"> This structure is

“An illegal choice is detected…” error with dynamic dropdown select list I Drupal8

流过昼夜 提交于 2020-03-25 16:04:59
问题 I wrote this code for dynamic dropdown select list in hook_form_alter. Options are populated by an external DB. function car2db_annuncio_form_alter(&$form, FormStateInterface $form_state, $form_id) { if ($form_id == 'node_annuncio_form') { $options_type = car2db_annuncio_type_dropdown_options(); $form['field_marca']['#prefix'] = '<div id="field_marca">'; $form['field_marca']['#suffix'] = '</div>'; $form['field_tipologia']['widget']['#options'] = $options_type; $form['field_tipologia']['widget

“An illegal choice is detected…” error with dynamic dropdown select list I Drupal8

房东的猫 提交于 2020-03-25 16:03:09
问题 I wrote this code for dynamic dropdown select list in hook_form_alter. Options are populated by an external DB. function car2db_annuncio_form_alter(&$form, FormStateInterface $form_state, $form_id) { if ($form_id == 'node_annuncio_form') { $options_type = car2db_annuncio_type_dropdown_options(); $form['field_marca']['#prefix'] = '<div id="field_marca">'; $form['field_marca']['#suffix'] = '</div>'; $form['field_tipologia']['widget']['#options'] = $options_type; $form['field_tipologia']['widget

Drupal 8 Can't persist custom template content type form

独自空忆成欢 提交于 2020-02-05 03:42:05
问题 I am trying to display and customize an add form page. My content type, created via admin interface, is simple but uses workbench moderation module to manage content entity state (draft, published and archived). I use this code to display form : my__module.routing.yml my__module.declare_security_practice: path: '/declarer-une-pratique-securite' defaults: _controller: '\Drupal\node\Controller\NodeController::add' _title: 'Déclarer une pratique sécurité' node_type: 'pratiques_securite'

How to delete part of the code in TWIG for Drupal?

允我心安 提交于 2020-01-25 08:39:26
问题 I use this code to print the flag in its node : {{ content.flag_like_node }} When I print my flag in the template of my node, the rendering is as follows : <div class="bs-field-like-link"><a class="collapsed" data-toggle="collapse" data-parent="#accordion" href="#collapse1"></a><div class="flag flag-like-store js-flag-like-store-13 action-unflag"><a class="collapsed" data-toggle="collapse" data-parent="#accordion" href="#collapse1"></a><a title="" href="/fr/flag/details/edit/like_store/13

How to make the address code on one line with TWIG?

半腔热情 提交于 2020-01-25 07:58:08
问题 I have a TWIG code to display the address of a store. Currently the address is rendered on 3 lines. How to make the address code on one line ? {{ store.address|render|trim|replace({'<br>': ' - '})|striptags|raw }} 回答1: Your are outputting the address inside a <pre> tag. The white-space of the <pre> tag is set to pre by default. See here for more information about this. So you have 2 options Replace the <pre> tag with a <div> <div> Lorem ipsum dolor sit amet </div> Overrule the white-space of