itmaybejj → credited wombatbuddy → .
Try to test in on Drupal 11 and if it working we create a new release for Drupal 11.
I read in "LiteSpeed Cache for Drupal" that it makes sense if the site is running on LiteSpeed Web Server or OpenLiteSpeed.
You can generate a custom module with the following Drush command:
drush generate module
And then install the module using the following command:
drush en -y [module_name]
Also, here is a one tutorial
"Creating modules" →
(you can find others on youtube).
You can download the ready-made custom module from this link https://limewire.com/d/zV1Tz#qIk4y9BaHW
Here are some references
1. API.
2.
Programmatically send test email →
.
3.
Programmatically send newsletter in hook_cron →
.
Let's say we have the "page" content type.
Visit /admin/structure/types/manage/page/display
and ensure that the format of the Body field is not "Trimmed" or "Summary or trimmed".
You can try the solutions suggested in issues #3280795 🐛 DivisionByZeroError: Division by zero in template_preprocess_image_style_preview() (line 51 of core/modules/image/image.admin.inc). Active and #3130741 🐛 Division by 0 in template_preprocess_image_style_preview Active .
I got it, thank you for the clear explanation!
Additionally, these broken links are present in the Tutorials → .
wombatbuddy → created an issue.
Here are some references:
1.
Cache API →
2.
Internal Page Cache →
.
It sounds promising, I'll try to learn this technique.
Looking forward to more info :)
wombatbuddy → created an issue.
You may try to uninstall the "Taxonomy Views Integrator" → module.
wombatbuddy → created an issue.
wombatbuddy → created an issue.
What about to use a content block and render a view in it with the module like Viewfield → ?
You can use the following modules:
1.
Fancy File Delete →
.
2.
Unmanaged / Unused Files | Manage | Delete →
.
Could you be more specific with the use case? But it looks like you can use the Field Permissions → and Layout Paragraphs → modules.
To hide the "weight" column we can use the following code:
if ($variables['element']['#field_name'] === 'field_exams_assignments_files') {
unset($variables['table']['#tabledrag']);
unset($variables['table']['#header'][1]);
foreach ($variables['table']['#rows'] as &$row) {
unset($row['data'][1]);
}
}
I confirm that the issue exists, also the module does not work for multi-value Media field.
(@joeyroth, as a workaround you can use the code I've shared here:
https://www.drupal.org/forum/support/module-development-and-code-questio... →
).
Let's assume that teachers have the role "teacher".
use Drupal\Core\Form\FormStateInterface;
/**
* Implements hook_form_FORM_ID_alter() for node_exams_and_assignments_edit_form.
*/
function my_module_form_node_exams_and_assignments_edit_form_alter(&$form, FormStateInterface $form_state, $form_id): void {
$current_user = \Drupal::currentUser();
// If the user does not have the role "teacher" then do nothing. This is
// necessary to give the ability to users with the role of administrator to
// edit files.
if (!$current_user->hasRole('teacher')) {
return;
}
foreach ($form['field_exams_assignments_files']['widget'] as &$item) {
if (is_array($item) && isset($item['#default_value']['target_id'])) {
$fid = $item['#default_value']['target_id'];
$file = \Drupal::entityTypeManager()->getStorage('file')->load($fid);
$fid = $file->getOwnerId();
if ($fid != $current_user->id()) {
// Hide the file if it was not uploaded by the current user.
// Alternatively, you can display the file but make it non-editable
// $item['#disabled'] = TRUE;
$item['#access'] = FALSE;
}
}
}
}
/**
* Implements hook_preprocess_HOOK() for file_widget_multiple templates.
*
* Disable tabledrag for field_exams_assignments_files.
*/
function my_module_preprocess_file_widget_multiple(&$variables) {
if (\Drupal::currentUser()->hasRole('teacher')) {
if ($variables['element']['#field_name'] === 'field_exams_assignments_files') {
unset($variables['table']['#tabledrag']);
}
}
}
jaypan, here are two articles that explain the purpose of the module:
1. Pluggable Entity View Builder - A Layout Builder for Developers.
2. How We Theme in Gizra with PEVB and a Composable Approach.
For now, the "Current Page Entity Tokens" → module can be used (however, it has a caching issue, see #3473821). Also, in the issue #919760 ✨ Add a [current-page:object:?] dynamic token Needs work the work is underway to provide access to the page entity using the token [current-page:ENTITYTYPE].
This is by design, you can use the [node:nid] token in node fields but not in other entities. However, work is underway to provide access to the page entity using the token [current-page:ENTITYTYPE], see issue
#919760
✨
Add a [current-page:object:?] dynamic token
Needs work
. Also, currently you can use the
"Current Page Entity Tokens" →
module which provide this feature (however it has caching issue
#3473821
🐛
Missing cache context url.path for usage in Block
RTBC
).
use Drupal\group\Entity\GroupInterface;
/**
* Implements hook_preprocess_HOOK() for page templates.
*/
function my_module_preprocess_page(&$variables) {
$group = \Drupal::routeMatch()->getParameter('group');
if ($group instanceof GroupInterface) {
$variables['group'] = $group;
}
}
wombatbuddy → created an issue.
/**
* Implements hook_preprocess_HOOK() for group templates.
*/
function my_module_preprocess_group(&$variables) {
$group = $variables['group'];
$group_type = $group->bundle();
}
The following code should work:
$form["#suffix"] = Markup::create('<span style="font-weight: bold;">test</span>');
Ensure that you export the Markup class (use Drupal\Core\Render\Markup;) and rebuild the caches.
It seems a custom code is needed. But as an alternative, you can try the FullCalendar Block → module. Here is what they say on the project page:
6. The 'Advanced setting' provides the capability to add or modify any options of the FullCalendar, which has to be valid JSON/YAML format text. For example, following will set the initial date at 2022-05-01,
"initialDate": "2022-05-01"
Please note that there are various ways to design a system for categorizing by location. One implementation, is the taxonomy_place module → that nests terms by country, state/province and city.
Also, the following modules can be a good addition to a solution based on hierarchical taxonomy:
1.
Simple hierarchical select →
.
2.
Client-side Hierarchical Select →
.
wombatbuddy → created an issue.
Added the info that the file name in the temporary folder may not match the original file name.
I try to fix the link to the following change record:
https://www.drupal.org/node/3363700 →
I try to fix the link to the following change record:
https://www.drupal.org/node/3363700 →
I try to fix the link to the following change record:
https://www.drupal.org/node/3363700 →
I described the process of uploading a file in more detail and added information that hook_file_validate() is deprecated in Drupal 10.2.0.
What happens to the knowledge if the company that supports Slack goes bankrupt?
The thing is that your profile doesn't indicate your skills. If it said that you are a Drupal developer and develop modules, I wouldn't offer my services. Good luck!
I am available to work on a custom module and you can contact me.
Guys,
I apologize for the off-topic, but I need a job, if your companies need developers, please mail to me. Thanks!
I've added smustgrave to the maintainers.
Here are some references
1. Webform 8.x-5.x - Computed Elements.
2. Custom Webform Element in Drupal.
3. Webform Custom Options Elements.
It looks like you can use both of the templates you mentioned at the same time.
Except now I need to add a select dropdown of all of the Main Topics.
Are you talking about node edit form? Please explain the use case.
I created a Drupal 11 compatible version of the
Node Revision Limit →
module and made a merge request here:
https://www.drupal.org/project/node_revision_limit/issues/3489468
📌
Drupal 11 compatibility
Active
wombatbuddy → created an issue.
Ok, please mail me via a contact from or email: wombatbuddy [at] gmail.com
Add info about the restriction of entity route parameters by specified bundles.
The reference: New 'bundle' property for the entity:* route parameters. The '_entity_bundles' route requirement is deprecated.
What about to use
if ( condition ) { render a form }
else { do not render } ?
If you need to left redirection just remove the save() method form the MyEntityForm class. The example
my_module.routing.yml
my_module.edit_nodes:
path: '/edit-nodes'
defaults:
_controller: '\Drupal\my_module\Controller\MyModuleController::editNodes'
requirements:
_permission: 'access content'
MyEntityForm.php
<?php
declare(strict_types=1);
namespace Drupal\my_module\Form;
use Drupal\Core\Form\FormStateInterface;
use Drupal\node\NodeForm;
/**
* Provides a My module form.
*/
final class MyEntityForm extends NodeForm {
/**
* {@inheritdoc}
*/
public function getFormId(): string {
// The dynamic form ID allows for the form to be
// reused on a page.
return parent::getFormId() . '-' . $this->getEntity()->id();
}
/**
* Redirect back to the Edit node forms.
*/
public function save(array $form, FormStateInterface $form_state) {
parent::save($form, $form_state);
$form_state->setRedirect('my_module.edit_nodes');
}
}
MyModuleController.php
<?php
declare(strict_types=1);
namespace Drupal\my_module\Controller;
use Drupal\Core\Controller\ControllerBase;
/**
* Class MyModuleController.
*/
class MyModuleController extends ControllerBase {
/**
* Render node edit forms.
*/
public function editNodes() {
$node1 = $this->entityTypeManager()->getStorage('node')->load(1);
$node2 = $this->entityTypeManager()->getStorage('node')->load(2);
$form1 = $this->entityFormBuilder()->getForm($node1, 'my_form_mode');
$form2 = $this->entityFormBuilder()->getForm($node2, 'my_form_mode');
return [
'#type' => 'container',
'#children' => [
'form1' => $form1,
'form2' => $form2,
],
'#title' => $this->t('Edit Nodes'),
];
}
}
What is the use case, why do you need to have several node forms on one page?
wombatbuddy → created an issue.
wombatbuddy → created an issue.
The reason why patch #2 is needed
In Drupal 11 PHPUnit has been upgraded from 9.5 to 10.5. And in PHPUnit 10 @dataProvider methods must be static.
References
1.
https://www.drupal.org/project/drupal/releases/11.0.0 →
2.
https://www.drupal.org/node/3365413 →
Tasks
1. In 1.0.x branch remove Drupal 11 support (core_version_requirement: ^10.2) and create a new release.
2. Create a new 2.0.x branch for Drupal 11 version (core_version_requirement: ^11), make changes, test it and create a new 2.0.1 release.
To increase your productivity as a developer, you can use the following tools:
1. Codeium.
2. ChatGPT.
3. Drush generate command.
To fix the issue replace the following line
with this one
$current_path_alias = \Drupal::service('path_alias.manager')->getAliasByPath($current_path);
Example of the code using dependency injection:
namespace Drupal\my_module\Plugin\Block;
use Drupal\Core\Block\BlockBase;
use Drupal\Core\Path\CurrentPathStack;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\path_alias\AliasManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Provides a myblock block.
*
* @Block(
* id = "my_module_myblock",
* admin_label = @Translation("MyBlock"),
* category = @Translation("Custom"),
* )
*/
final class MyblockBlock extends BlockBase implements ContainerFactoryPluginInterface {
/**
* Constructs the plugin instance.
*/
public function __construct(
array $configuration,
$plugin_id,
$plugin_definition,
private readonly CurrentPathStack $pathCurrent,
private readonly AliasManagerInterface $pathAliasManager,
) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition): self {
return new self(
$configuration,
$plugin_id,
$plugin_definition,
$container->get('path.current'),
$container->get('path_alias.manager'),
);
}
/**
* {@inheritdoc}
*/
public function build(): array {
$path = $this->pathCurrent->getPath();
$alias = $this->pathAliasManager->getAliasByPath($path);
$build = [];
$build['#markup'] = $this->t('Alias: @alias', ['@alias' => $alias]);
return $build;
}
}
You can store a webform data using State API → or user.data service. You can create a controller which will get data from the state and return them to with the AjaxResponse or JsonResponse. Then you can attach the JavaScript library to the webform 1 → and do the Ajax request to the controller. Also, you can extract the data from the state in the hook_form_FORM_ID_alter for the webform 1 and modify it.
And what’s the best way to set up embedded viewing for interactive content within Drupal?
You may look at the H5P → module.