Drupal StackExchange

Setting up a date field to require an end date

1 day ago

I'm attempting to create a custom content type for a module via hook_install. When I create a date type (from Date module), I want it to require an end date (there's a checkbox when you're setting up the field via the gui). This is the settings array for the field:

'settings' => array( 'enddate_get' => 1, 'enddate_required' => 1, ),

This isn't working (the widget is still only asking for one date), so I'm guess that I have the wrong settings. Does anyone know how to properly set this up?

gregghz

Is it possible to create a hierarchical exposed filter in views using the Data module?

1 day 1 hour ago

I'm using Data module to adopt tables from the same DB as 'native' Drupal tables and Views module to present the data.

I added two dropdown exposed filters with Selective filter module. It takes all values from fields and puts them to the selective list. It works fine.

However I would like to configure my exposed filters the way that the second filter will show values according to the chosen value in the first one. E.g. if you choose a specific academic department in the first filter, the second one will offer you the list of this department's staff members.

Is it possible to achieve such a behavior? If so, do I need any extra modules (taxonomy?) or should I create a module myself?

Khrystyna Zub

How do I apply path alias patch?

1 day 2 hours ago

I am updating a site from Drupal 8.7 to Drupal 8.8, and after running a drush updb, I encountered this error:

[error] TypeError: Argument 2 passed to Drupal\pathauto\AliasStorageHelper::__construct() must be an instance of Drupal\path_alias\AliasRepositoryInterface, instance of Drupal\Core\Path\AliasRepository given, called in drupal/core/lib/Drupal/Component/DependencyInjection/Container.php on line 289 in Drupal\pathauto\AliasStorageHelper->__construct() (line 79 of drupal/modules/contrib/pathauto/src/AliasStorageHelper.php) #0 drupal/core/lib/Drupal/Component/DependencyInjection/Container.php(289): Drupal\pathauto\AliasStorageHelper->__construct(Object(Drupal\Core\Config\ConfigFactory), Object(Drupal\Core\Path\AliasRepository), Object(Drupal\Core\Database\Driver\mysql\Connection), Object(Drupal\pathauto\VerboseMessenger), Object(Drupal\Core\StringTranslation\TranslationManager), Object(Drupal\Core\Entity\EntityTypeManager))

I found a similar issue in this link here and there seems to be a solution(patch) for it.

EDIT:

I ran a composer command attempting to fix the path alias error:

composer require 'drupal/pathauto:1.x-dev@dev'

Ran composer update, and drush updb. The following is the error displayed by the console:

> [error] Argument 2 passed to Drupal\pathauto\AliasStorageHelper::__construct() must be an instance of Drupal\path_alias\AliasRepositoryInterface, instance of Drupal\Core\Path\AliasRepository given > [error] Update failed: block_field_update_8001 > PHP Fatal error: Uncaught ReflectionException: Class Drupal\path_alias\AliasRepository does not exist in /var/www/html/docroot/vendor/symfony/dependency-injection/ContainerBuilder.php:1174 > Stack trace: > #0 /var/www/html/docroot/vendor/symfony/dependency-injection/ContainerBuilder.php(1174): ReflectionClass->__construct('Drupal\\path_ali...') > #1 /var/www/html/docroot/vendor/symfony/dependency-injection/ContainerBuilder.php(634): Symfony\Component\DependencyInjection\ContainerBuilder->createService(Object(Symfony\Component\DependencyInjection\Definition), Array, true, 'path_alias.repo...') > #2 /var/www/html/docroot/vendor/symfony/dependency-injection/ContainerBuilder.php(1281): Symfony\Component\DependencyInjection\ContainerBuilder->doGet('path_alias.repo...', 1, Array, true) > #3 /var/www/html/docroot/vendor/symfony/dependency-injection/ContainerBuilder.php(1238): Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices(Object(Symfony\Component\DependencyInjection\Reference), Array, true) > #4 /var/www/html/docroot/ in /var/www/html/docroot/vendor/symfony/dependency-injection/ContainerBuilder.php on line 1174 [error] Update aborted by: system_update_8803, block_field_update_8001 [error] Finished performing updates.

Is there anything else I can do with the pathauto module?

Sidney Sousa

Field-Group Tabs not displaying on product page

1 day 3 hours ago

I'm trying to display a handful of fields as tabs on my product detail pages, but it seems that the field-group tabs are being completely ignored by the Commerce product display. Anyone else have this problem? Did I miss something in the tab setup/display?

The fields display as any other field for the Product, just output as regularly expected. As mentioned, just seems to ignore the 'tabs' display.

Bill C

showing translation of the related node in view

1 day 4 hours ago

I have a node type called Match. Each match have two entity reference fields that points to two nodes that has the type of Team. I built a view and use the relationship to show the matches and the information of the host team and guest team and it's fine. My problem is that the Team node is multilingual and I want to show the translation of Team fields in the view. It is obvious that the fields has a reference to the original untranslated node ID and when I use the relationship in the view it will grab that node even if it has translations.

Mojtaba Es

Prevent Quick Editing on certain DOM elements

1 day 5 hours ago

I want to enable quick edit within a block which contains some JS libraries (such as slick). As slick changes the DOM, when I use quick edit it saves this altered DOM and then the slick library doesn't work.

Simplified example:

Saved HTML (pre-page load)

<div class="slick"> <li> <ul>Tile 1</ul> <ul>Tile 2</ul> </li> </div>

Rendered HTML (page loaded)

<div class="slick"> <div class="slick-magic etc"> <li> <ul>Tile 1</ul> <ul>Tile 2</ul> </li> </div> </div>

As the slick JS code adds the extra DOM content, when the user saves something via quick edit, the extra DOM content is saved to the page. Subsequently, when slick is rendered again by the JS, we get a slider that doesn't work.

Is there a way to prevent quick edit from applying changes to anything within <div class="slick">? Alternatively, is there a place where I can use slick's destroy method to the object before the block changes to edit mode?

Note:

  • Have tried using Bootstrap's carousel which doesn't alter the DOM but the functionality is too limited to match what slick can provide

Edit:

The JS object resides within a block. I still need to use quick edit to edit the block, but also to protect the JS object

aydow

Comments not displayed

1 day 6 hours ago

On my Drupal 8 I have a blog, which should have a comment function. I added the comment field in the content type of the blog posts and I also checked the checkbox that the comment input field is shown. But the comment section is not displayed. Even in my template file in my theme_preprocess_node function I could not find the comment field. I also tried it with the Bartik theme, but that also didn't work.

My question now is: How can I display the comments section on my blog articles?

manueldu

How to create a view showing Users who have flagged AND are flagged by the current user

1 day 7 hours ago

I'm trying to display a list of users who have flagged the current user, and are flagged by the current user. So a two-way flagging.

I've tried using different relationships and arguments in views, but can't seem to get the combination right. Any tips? Thanks!

Here's my views config from @pkros's instructions as requested.

Also, here is a quick screencast showing the issue in action... https://drive.google.com/file/d/1MOXKZSq_cjPRv6moim1a5ikKeeD8mjY9/view?usp=sharing

Yuckle

Concatenate two fieds in an EntityQuery condition

1 day 8 hours ago

I'm trying to query some nodes by a given string checking if the string is either in the node title OR if the string is an exact match of concatenating the value of two strings.

I know this should be possible in normal mysql but not sure it can be translated in an entity query. Has anyone stumbled upon this problem before?

Is there some sort of 'free text' condition which is not tied up to fields.

At the moment the below code complains about the fact that CONCAT_WS(...) is not a field which is true.

Maybe there is a simpler solution to this but I'm just not seeing it.

$query = \Drupal::entityQuery('node') ->condition('status', 1) ->condition('type', 'CONTENT_TYPE'); $group = $query->orConditionGroup() ->condition('title', $string , 'CONTAINS') ->condition("CONCAT_WS('',FIELD_1,FIELD_2)", $string); $query->condition($group); $nids = $query->execute();
Titi

How can I programmatically set a custom homepage?

1 day 9 hours ago

I have a system where a user can add a custom domain, for example *domain.com, in a text field. For example in node 10. This custom domain should, when entered in the browser, end up in showing the node where the custom domain is filled in.

I can get this partly working using a EventSubscriber but the problem is that when the url is filled in the url changes. So I go to domain.com and the url instantly changes to domain.com/node/10. Is there a way to do this differently so the url stays the same?

I am looking for a Drupal solution, not a htaccess solution. And one using a custom module or custom code I don't want to use the Domain module.

Joost