It sounds like you can use
Paragraphs →
(or
Custom Field →
),
Recurring Dates Field →
, Geofield and
Address →
modules.
1. Create a new Paragraphs type named Event with two fields:
1) Date ("Recurring Dates Field" field type);
2) Location (Geofield or Address field type);
2. Add to the Club content type the Event field of the "Entity Reference Revisions" type (Paragraphs).
After that you will be able to add events with different locations. What modules are you currently using?
Sorry, I didn't understand the use case. Could you please rephrase the problem description? Also, please let me know what fields the club page has and where the map you're talking about is displayed.
My libraries file:
react-components-lib:
version: 1.x
js: js/react-app/app_bundle/app.bundle.js: {}
dependencies:
- core/drupal
- core/jquery
- core/drupal.init
- core/drupalSettings
1. "core/drupalSettings" does not need to be added to dependencies as it is already added in core/drupal
2. It looks like the "core/drupal.init" is a non-existent library.
3. Since you specify the library version, I hope you do it consciously. But just in case, I will leave the following information here:
"Starting from Drupal 10.1.2, the version information within a library definition plays a critical role in generating a unique hash for aggregated files. Consequently, it is imperative that the "version" in a library definition is updated whenever a referenced CSS/JS file undergoes changes.
Alternatively, if the version is omitted, the prior behavior will apply, where the content of referenced CSS/JS files is utilized in the hash.
Incorrect usage of version information could lead to browser and edge cache invalidation issues.
See this update → on the related changelog → ".
I'm not sure if the
jQuery(document).ready
is necessary
You don't need this in Drupal.behaviors.
Eventually, I found a hack. I put this in my behaviors:
if (Object.entries(settings).length === 0) {
console.log("HACK TO FIX SETTINGS");
settings = JSON.parse(
document.querySelector(
'[data-drupal-selector="drupal-settings-json"]'
).textContent
);
}
Depending on your use case, this may lead to an error. There are three places where settings are stored: 1) In the HTML element that you're using 2) In the global window.drupalSettings object 3) In the settings variable. During the initial page load, data is written to the HTML element and doesn't change with subsequent AJAX updates. However, during AJAX updates, the data in the window.drupalSettings and settings variables may change. This means you'll most likely need to ensure that you're reading data either from the drupalSettings object or from the settings variable.
References
1. Understanding JavaScript behaviors in Drupal.
2. What's the difference between drupalSettings and settings parameter in behaviors?
3.
SettingsCommand →
.
My client insists that the application form has to be in the docx format rather than some sort of webform on the page.
Can you ask him what this requirement means exactly?
I think the possible workflow might be like this:
1. A client creates a .docx template of an application form.
2. The .docx template is rendered to HTML using JavaScript.
3. To collect user data, the HTML template is modified to replace placeholders with HTML input elements.
4. After user input is collected, the final .docx is generated.
You can look at the following JS libraries: docxtemplater, docx-templates, mammoth.js.
It sounds like you can do it with the EVA → or the Views field formatter → modules.
Since the release 3.0.1 it's possible to convert Image fields to Media using update hooks. So, as a workaround, you can implement hook_post_update_N() and run it with the following Drush command: drush upd
For more information and an example, see the module's home page.
wombatbuddy → created an issue.
We need to fork the issue, make the changes and create a pull request. We should then change the issue status to "Needs review" so the community can thoroughly test the changes.
The following settings should work for your JSON:
Since your JSON represents an array of objects at the root level, the Apath should be configured as follows:
Apath: /After setting the correct Apath, you will be able to add the following JSON Fields to your view:
companyname - Key Chooser: companyname
ecoCountry - Key Chooser: country/ecoCountry
address - Key Chooser: address
town - Key Chooser: town.
Also add the contextual filter to replace the wildcard('%') with 'data'?
how to do this ??
This cannot be applied to your JSON structure because:
1. No nested structure - data is directly in the root array.
2. No different "categories" of data - all objects are the same type (companies).
3. No alternative paths - there's only one path to the data.
The wildcard would be useful if your JSON looked like this:
{
"ghana": [
{"companyname": "Company 1", ...},
{"companyname": "Company 2", ...}
],
"nigeria": [
{"companyname": "Company 3", ...},
{"companyname": "Company 4", ...}
]
}
in this case we could set the following values:
Apath: %
Contextual filter: replaces % with "ghana" or "nigeria"
URL: /companies/ghana or /companies/nigeria.
Since your JSON represents an array of objects at the root level, the Apath should be configured as follows:
Apath: /
After setting the correct Apath, you will be able to add the following JSON Fields to your view:
companyname - Key Chooser: companyname
ecoCountry - Key Chooser: country/ecoCountry
address - Key Chooser: address
town - Key Chooser: town.
What about the Smart Date → module?
- Timezones - Smart Date allows an editor to specify a timezone per date, in case your site needs to show dates in multiple timezones. When using this, the time in the user/site's timezone is also shown, for clarity.
1. If name of your template is "field--field-rating" and the theme name is "v1" then the function name should be like this:
function v1_preprocess_field__field_rating(array &$variables) {}
2.
The correct way is to pass the "key" variable without quotes:
<span{{ attributes.addClass(key) }} data-rating="{{ key }}">{{ item.content }}</span>
I can't get either of those methods to work, at least not completely. I tried the theme code first, since I agree that adding the functionality there could be useful in future, but nothing changed. I removed my own template just in case, but no luck.
Share the following things and we'll try to help:
1) The field name
2) The Twig template you are using
3) Theme name
4) Your code.
The template code seems to work in so far as I can print {{ key }} in an attribute, which is usable for my purpose, but I didn't have much clue about how to add it to my existing class. I only know how to add one class at a time.
I didn't understand your problem, please rephrase it. What is the respected result? Provide an example of the code you want to achieve etc.
If you are allowed to choose only one value, then you can use this code:
{% set key = element['#items'].getString() %}
or this
{% set key = element['#object'].get('field_name').value %}
A universal solution would be to add a key to classes in the preprocess function. Add this code to YOUR_THEME_NAME.theme or to a custom module:
/**
* Implements hook_preprocess_HOOK() for field templates.
*
* Adds a key of the item of List field as classes to field items.
*/
function olivero_preprocess_field__field_list(array &$variables) {
foreach ($variables['element']['#items'] as $item => $item_data) {
// Get a key of the item of a List filed.
$key = $item_data->value;
$variables['items'][$item]['attributes']->addClass($key);
}
}
How many values can be selected from the list, one or more?
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.