Drupal StackExchange

hook_editor_js_settings_alter()

1 month 3 weeks ago

I am using hook_editor_js_settings_alter() to disallow HTML tags in Ckeditor. It is only working in node edit form, and Ckeditor is in edit mode. Wen I preview the published page it allows the tags in my disallow custom hook.

The following code was a test to disallow <h1> tags with the class name myHeader2. If I change the class name to myheader, it work in edit mode and published mode. Is the class name the problem?

use Drupal\Core\Form\FormStateInterface; use Drupal\editor\Entity\Editor; function mymodule_editor_js_settings_alter(array &$settings) { foreach ($settings['editor']['formats'] as $name => $value) { $settings['editor']['formats']['rich_text']['editorSettings']['disallowedContent'] = 'h1(myHeader2)'; } }
paul cappucci

Add print button in the "Review order" page

1 month 3 weeks ago

I want to know, is there any way to add print button to "Review order" page.

by clicking this button, a pop up page is loaded with good style for print mode and user can print the cart items , taxes and all information in Review order page.

Please guide me.

Mehrdad201

SearchApiQuery - possible to remove a filter?

1 month 3 weeks ago

The query parameter that is passed to search_api_query_alter has SearchApiQueryFilter member. It contains a protected array of filter elements. I can add to this by calling the createFilter() and filter() methods, but it does not appear that there is a way to remove a filter through the API. Can this be done?

cdonner

How to set Panel to homepage when setting the panel's path as homepage on Configuration > Site Information doesn't work?

1 month 3 weeks ago

I have created a panel for my home page and set its path to /home. I have changed the directory of the front page in Admin > Configuration > Site Information to mysite.com/home. Still, when I visit mysite.com/home, the custom panel saved to path /home doesn't populate.

I've made sure I'm saving correctly (rather than just updating) and have also cleared my cache.

Any ideas how else I might be able to fix?

Thanks in advance!

user2865430

How do I output XML schema?

1 month 3 weeks ago

I have set the REST server with the Services module.

Also I've installed the Services Views module, created a new view that outputs the desired fields into XML.

That's working fine.

How can I add XML schema to that output, so the XML will look like:

<?xml version="1.0"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> .....
user2519032

Modifying a custom form on submit

1 month 3 weeks ago

I have a custom module with a custom form, Drupal 10, and when the form is submitted I want to either 1. add some markup to the submitted page or 2. change a value on the form. I have failed on the former, so I am trying the latter.

Here's my code, without the chaffe:

public function buildForm(array $form, FormStateInterface $form_state): array { $form['plate'] = [ '#type' => 'textfield', '#title' => $this->t('Plate'), ]; $form['actions'] = [ '#type' => 'action', 'submit' => [ '#type' => 'submit', '#value' => $this->t('Search'), ], ]; } public function submitForm(array &$form, FormStateInterface $form_state): void { $this->messenger()->addStatus($this->t('The form has changed')); $form_state->setValue('plate', 'Changed Value'); $form_state->plate = [ '#type' => 'textfield', '#title' => $this->t('Plate wjiijowqoiwefewiofjewfio'), '#value' => 'Changed Value', '#default_value' => 'Changed Value', ]; $form_state->plate['#value'] = "Changed Value"; $form_state->setRebuild(); }

Can you see where I am going wrong?

Banners

theme contact form block

1 month 3 weeks ago

I am using contact_form_blocks-7.x-1.x-dev module. Using this module I have embedd contact us form in my website. For themeing I have created file named block--contact.tpl.php. Cleared cache, but it doesnt result anything.
How should I theme this contact us form?

Yogesh

Webform email handler - dynamic recipient list

1 month 3 weeks ago

Our site uses webforms and for a particular form - upon submission - an email is sent to multiple people. Currently, that recipient list is part of 'config' - meaning that to add/delete someone is a config change and since we are using best practice of configuration as code - this means pushing a new release. I am looking for a way to create the recipient list dynamically - say based on a user attribute - so that a site admin/editor could modify it and not require a code push.

jwag

What is the correct order of disabling the default contact form on Drupal?

1 month 3 weeks ago

Drupal comes with a default contact form on each site we install. And while we already have the webforms and recaptcha module installed, some of our site owners still use the default contact form found in /admin/structure/contact.

I need to remove them because when they are enabled, the site is prone to spam attacks. I've had a few instances where some of the sites had form submissions with PDF file uploads of inappropriate content. So you see how this is a security risk for our organization.

I removed that contact form in my local site by disabling the following modules in this order:

  • contact form
  • contact storage
  • contact

But I need to do this for all our sites now, so I wrote the following in my hook_update_n() function:

function my_profile_update_8011() { $config = \Drupal::configFactory(); $moduleHandler = \Drupal::service('module_handler'); if($moduleHandler->moduleExists('lightning_contact_form')) { Drupal::service('module_installer')->uninstall(['lightning_contact_form']); } if($moduleHandler->moduleExists('contact_storage')) { Drupal::service('module_installer')->uninstall(['contact_storage']); } if($moduleHandler->moduleExists('contact')) { Drupal::service('module_installer')->uninstall(['contact']); } }

When I deployed this update to our dev environment, it would work on most of the sites, but fail on the rest. They all have this same error message:

The error output from the server was: > [notice] Update started: my_profile_update_8011 > [error] SQLSTATE[42S22]: Column not found: 1054 Unknown column 'id' in 'where clause': SELECT 1 AS expression > FROM > {contact_message} t > WHERE id IS NOT NULL > LIMIT 1 OFFSET 0; Array > ( > ) > > [error] Update failed: my_profile_update_8011 [error] Update aborted by: my_profile_update_8011 [error] Finished performing updates.

All our sites share the same codebase, so I don't know where my update hook went wrong. Is there a better way of disabling these modules?

thanks, Kevin

kcsting