Drupal StackExchange

How to safely output user input HTML in a twig theme [duplicate]

1 day 21 hours ago

Very basic question:

I have a twig template were I want to output the HTML content of a CkEditor managed field within a node.

<div class="wrap-user-html"> {{ node.field_myfield.0.value }} </div>

This does not work, as it prints the html code with html entities. I'm getting e. g.

<div class="wrap-user-html"> &lt;p&gt;foo&lt;/p&gt; </div>

I could use |raw and it would work, but I read this is unsafe. Also when using raw, text format filters from the ckeditor settings seem to not get applied.

How do I do this right?

c1u31355

Programmatically add a translation with proper content moderation state

1 day 22 hours ago

I am trying to add a node translation programmatically when a node is created (using hook_ENTITY_TYPE_insert). My code works fine except that the translation doesn't really have a content moderation state. My code is the following.

function mymodule_add_translation($node) { // get the current language, and determine the translation language $lang = \Drupal::languageManager()->getCurrentLanguage()->getId(); $langcode = ($lang == 'en') ? 'fr' : $lang; $node->setRevisionTranslationAffected(FALSE); $node->addTranslation($langcode, ['title' => $node->getTitle()])->save(); }

This is what the content_moderation_state_field_revision table looks like for two nodes; the first one was manually translated and the second one was translated using the above code.

I am clearly doing something incorrect. Any suggestion would be really appreciated.

JoelB

How do I implement the login, register and "Forgotten password" forms?

1 day 23 hours ago

I'm trying to implement the three Drupal 8 user forms : login, register account and forgotten password forms.

I'm creating custom pages in my module for each one of them because I want to display content around those forms, change titles, hook the forms.

I'm having a hard time to do it, especially to get those forms in order to send them to the template and render them.

romain ni

Changing group visibility needs group content to be resaved when group content visibility field is set to "Use group defaults"

2 days ago

Drupal Commons 7.x-3.2
Organic Groups 7.x-2.1

Content type: Mygroup
Field: Group visibility - value: Public

Content type: Mypost
Field: Group - default value: Mygroup
Field: Group content visibility - default value: Use group defaults

Now when I create a group and a post based off on these content types everything is fine. As in everything is visible for all users.

Now when I change the Group visibility to Private I would except the post to not be visible anymore (because of the Use group defaults setting.

Unfortuanetely that's not working until I resave the post content. Then it will respect it's parent's settings.

This bug is mentioned in this video (around 6 min)

Does anyone know how to solve this problem?

devunder

Adding a webform in a webform confirmation

2 days 1 hour ago

I've been given a requirement to allow for a webform to be inserted into another webform's confirmation page.

At first I tried this with a token I could insert into the confirmation message, the form appears fine, but of course, the new webform is inside of the "parent" webform, which strips out the form tag.

So now I have overriden a few of the webform and webform submission entities handlers, so I can write my own custom getCustomForm function, I can get the new form appearing, but the submit behaviours are weird.

I've tried many things including:

return Webform::load( $webform->getThirdPartySetting('my_module', 'webform') )->getSubmissionForm();

and

$form['confirmation'] = [ '#type' => 'webform', '#webform' => $webform->getThirdPartySetting('wwf_fields', 'webform'), '#source_entity' => $webform, '#message' => [ '#type' => 'inline_template', '#template' => $webform->getSetting('confirmation_message') ] ];

Is there some combination of code I'm missing, or am I trying to bend the system a little too much?

Thanks!

user69676

Updating core to 8.9.6 fails

2 days 2 hours ago

I'v installed Drupal 8 by composer. Everything worked fine, but when I tried to update core from 8.9.1 to 8.9.5 in ended up in 8.9.4.

Today I tried to update from 8.9.4. to 8.9.6 by changing composer.json to demand v 8.9.6 at least.

The result was following error message:

Your requirements could not be resolved to an installable set of packages. Problem 1

  • Installation request for symfony/http-kernel (locked at v3.4.41) -> satisfiable by symfony/http-kernel[v3.4.41]. > - drupal/core-recommended 8.9.6 requires symfony/http-kernel v3.4.44 -> satisfiable by symfony/http-kernel[v3.4.44]. > - drupal/core-recommended 8.9.x-dev requires symfony/http-kernel v3.4.44 -> satisfiable by symfony/http-kernel[v3.4.44]. > - Conclusion: don't install symfony/http-kernel v3.4.44 > - Installation request for drupal/core-recommended ^8.9.6 -> satisfiable by drupal/core-recommended[8.9.6, 8.9.x-dev].

I'm stuck, since I don't know what locks symphony/http-kernel to v3.4.41.

I'm still pretty new with composer and would be glad if anybody could help me. Thanks a lot.

EDIT 1

{ "name": "drupal/legacy-project", "description": "Project template for Drupal 8 projects with composer following drupal/drupal layout", "type": "project", "license": "GPL-2.0-or-later", "homepage": "https://www.drupal.org/project/drupal", "support": { "docs": "https://www.drupal.org/docs/user_guide/en/index.html", "chat": "https://www.drupal.org/node/314178" }, "repositories": [ { "type": "composer", "url": "https://packages.drupal.org/8" } ], "require": { "civicrm/civicrm-asset-plugin": "~1.0.0", "civicrm/civicrm-core": "~5.28", "civicrm/civicrm-drupal-8": "~5.28", "civicrm/civicrm-packages": "~5.28", "composer/installers": "^1.2", "drupal/admin_toolbar": "^2.2", "drupal/antibot": "^1.4", "drupal/at_tools": "^3.2", "drupal/barrio": "1.x-dev", "drupal/captcha": "^1.0", "drupal/clever_theme_switcher": "^3.0", "drupal/colorbox": "^1.4", "drupal/commerce": "^2.17", "drupal/commerce_shipping": "^2.0@RC", "drupal/core-composer-scaffold": "^8.9.6", "drupal/core-project-message": "^8.9.6", "drupal/core-recommended": "^8.9.6", "drupal/core-vendor-hardening": "^8.", "drupal/ctools": "^3.4", "drupal/editor_advanced_link": "^1.6", "drupal/editor_file": "^1.4", "drupal/entity_browser": "^2.4", "drupal/hotkeys_for_save": "^1.0", "drupal/imce": "^2.3", "drupal/layout_builder_kit": "^1.0@beta", "drupal/layout_builder_modal": "^1.0", "drupal/linkit": "^4.3", "drupal/media_library_theme_reset": "^1.0@beta", "drupal/menu_block": "^1.5", "drupal/menu_item_role_access": "^2.0", "drupal/mobile_device_detection": "^3.2", "drupal/module_filter": "^3.1", "drupal/nagios": "^1.9", "drupal/pathauto": "^1.6", "drupal/permissions_by_term": "^2.18", "drupal/pixture_reloaded": "^3.0", "drupal/printable": "^1.1", "drupal/quick_node_clone": "^1.12", "drupal/redirect": "^1.5", "drupal/superfish": "^1.3", "drupal/swiftmailer": "^2.0@beta", "drupal/token": "^1.6", "drupal/upgrade_status": "^2.0", "drupal/views_conditional": "^1.0", "drupal/views_slideshow": "^4.7", "drupal/webform": "^5.9", "drupal/webform_civicrm": "^5.0@beta", "drupal/xmlsitemap": "^1.0@RC", "wikimedia/composer-merge-plugin": "^1.4" }, "conflict": { "drupal/drupal": "*" }, "minimum-stability": "dev", "prefer-stable": true, "config": { "sort-packages": true }, "extra": { "drupal-scaffold": { "locations": { "web-root": "./" } }, "installer-paths": { "core": [ "type:drupal-core" ], "libraries/{$name}": [ "type:drupal-library" ], "modules/contrib/{$name}": [ "type:drupal-module" ], "profiles/contrib/{$name}": [ "type:drupal-profile" ], "themes/contrib/{$name}": [ "type:drupal-theme" ], "drush/Commands/contrib/{$name}": [ "type:drupal-drush" ], "modules/custom/{$name}": [ "type:drupal-custom-module" ], "themes/custom/{$name}": [ "type:drupal-custom-theme" ] }, "merge-plugin": { "include": [ "modules/contrib/webform/composer.libraries.json" ] }, "drupal-core-project-message": { "include-keys": [ "homepage", "support" ], "post-create-project-cmd-message": [ "<bg=blue;fg=white> </>", "<bg=blue;fg=white> Congratulations, you’ve installed the Drupal codebase </>", "<bg=blue;fg=white> from the drupal/legacy-project template! </>", "<bg=blue;fg=white> </>", "", "<bg=yellow;fg=black>Next steps</>:", " * Install the site: https://www.drupal.org/docs/8/install", " * Read the user guide: https://www.drupal.org/docs/user_guide/en/index.html", " * Get support: https://www.drupal.org/support", " * Get involved with the Drupal community:", " https://www.drupal.org/getting-involved", " * Remove the plugin that prints this message:", " composer remove drupal/core-project-message" ] } }

}

My update command was

composer u drupal/core* --with-dependencies
paul77

Strict case in content URL alias

2 days 3 hours ago

(Pathauto: Leave case the same as source token values)

When I create a node with "Nullam vehicula pharetra" as title, the Pathauto module will create /content/Nullam-vehicula-pharetra as URL alias. But we can browse the same content with a different URL case, such as /content/NULLam-vehicula-pharetra.

How do I make Drupal strict on the URL alias case?

Wikipedia is good example about what I need. Two different case request return different contents:

jibotak

Drupal Planet

LN Webworks: How Can Drupal Commerce Drive Your E-Commerce Revenue to New Heights?

1 day 22 hours ago

Every e-commerce platform is different and comes with its own unique and specific needs. Some can use simple ready-made tools, while others need special software made just for them. New trends like smart personalization, easy shopping on phones, and caring for the environment are also important for online shops.

To help businesses achieve personalized website goals, Drupal comes into the scene. It's like a toolbox that lets you build your online store just the way you want. Drupal commerce is great because it's flexible and lets you try out new ideas. But there’s more to it. 

Today, we'll learn more about what makes Drupal Commerce special, like its features and how it's built.

Talking Drupal: Skills Upgrade #4

1 day 22 hours ago

Welcome back to “Skills Upgrade” a Talking Drupal mini-series following the journey of a D7 developer learning D10. This is episode 4.

Topics Resources

Chad's Drupal 10 Learning Curriclum & Journal Chad's Drupal 10 Learning Notes

The Linux Foundation is offering a discount of 30% off e-learning courses, certifications and bundles with the code, all uppercase DRUPAL24 and that is good until June 5th https://training.linuxfoundation.org/certification-catalog/

Hosts

AmyJune Hineline - @volkswagenchick

Guests

Chad Hester - chadkhester.com @chadkhest Mike Anello - DrupalEasy.com @ultimike