#StackBounty: #8 #taxonomy-terms #plugins How to correctly modify Taxonomy Term selection Plugin

Bounty: 50

I want some slight modifications of DrupaltaxonomyPluginEntityReferenceSelectionTermSelection::getReferenceableEntities(), for example to not use - to indicate term hierarchy. How can that be achieved?

I tried to extend that class in a custom module like that:

/**
 * Provides specific access control for the taxonomy_term entity type.
 *
 * @EntityReferenceSelection(
 *   id = "default:custom_taxonomy_term",
 *   label = @Translation("Custom Taxonomy Term selection"),
 *   entity_types = {"taxonomy_term"},
 *   group = "custom",
 *   weight = 2
 * )
 */
class CustomTermSelection extends TermSelection {

  /**
   * {@inheritdoc}
   */
  public function getReferenceableEntities($match = NULL, $match_operator = 'CONTAINS', $limit = 0) {
    // Customization will be here...
  }
}

The plugin seems to be detected, it appears while debugging $selection_plugins in DrupalCoreFieldPluginFieldFieldTypeEntityReferenceItem::fieldSettingsForm(), but it won’t appear as reference method on editing the term reference field.

What else do I need to modify to get it work?


Get this bounty!!!

#StackBounty: #8 #features #configuration-management Features along with configuration synchronization

Bounty: 50

I am planning to use features to bundle some of my specific works. Example: I want to bundle article content types along with its views, fields and related other stuffs. Can I just use features to create new article module through features ui and use it? How would it behaves when there is already configuration related to article in my sync folder which contains entire site configuration? Does anyone has experience on working with both of them simultaneously?

Thanks,

CIsSharp


Get this bounty!!!

#StackBounty: #8 #fields #rules Auto fill content field with random values

Bounty: 50

I have field_x with values “A” or “B”.

  • They must be assigned randomly by the system between A or B at every node added ( must not be changed on “node edit” by the node author).
  • The total numbers of nodes will be “30” and the assignment must be symmetrical ( after all 30 nodes will be added: 15 nodes must have “A” value and 15 nodes “B” value)

I’ve tried an solution with RULES but I didn’t find an random function to use. Anyone has an better solution ? Thank you!


Get this bounty!!!

#StackBounty: #8 #nginx Does the Nginx default block suffice?

Bounty: 200

The following conf file is my default Nginx conf (it’s basically the one shipped with Nginx 1.10.3 in Ubuntu).

server {
    # listen, root, index, server_name, locations;
    listen 80 default_server;
    listen [::]:80 default_server;
    root /var/www/html;
    index index.php index.html index.htm index.nginx-debian.html;
    server_name _;

    location / {
        try_files $uri $uri/ =404;
    }
    location ~ .php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    }
}

This is my individual app Nginx configuration.

server {
    root ${drt}/${domain}/;
    server_name ${domain} www.${domain};
    location ~* .(jpg|jpeg|png|gif|ico|css|js|ttf|woff|pdf)$ { expires 365d; }
}

Are these Nginx configuration files enough for basic, all-default Drupal usage (i.e. all core, no module customization, and up to 5 typical third-party modules)?

Enough in the sense of getting Drupal 8.4.x or later to work, with basic security.


Get this bounty!!!

#StackBounty: #8 #migration Using migrate_lookup process plugin to reference items processed later in the same migration

Bounty: 50

I’m trying to import data from custom source through Migrate in Drupal 8. The problem is that I need to process data which have references to each other. This is excerpt from my migration articles:

field_recommended_articles:
    -
      plugin: string_in_array
      key: id
      source: recommended_articles
    -
      plugin: migration_lookup
      migration: articles
      source: id

This seems to lead to recursion, because following error appears with stack trace containing repeating calls to respective migrate-related methods.

PHP Fatal error:  Maximum function nesting level of '2000' reached, aborting! in .../core/lib/Drupal/Core/Database/Statement.php on line 153

How can I solve this?

The recursion was caused by xdebug. Without it, there is a reference value created, but each value references the same content.


Get this bounty!!!

#StackBounty: #8 #nodes #i18n-l10n How to create translations programmatically?

Bounty: 50

I have a batch in which i’m importing nodes from REST webservices.
My application has two languages, FR and EN (default is FR).
So, I’m creating the node in FR, then, I loop through all other languages (just EN for now) and try to do as following :

$languages = Drupal::languageManager()->getLanguages();
unset($languages['fr']);

foreach ($languages AS $langcode => $language) {
  if ($node->hasTranslation($langcode)) {
    $node_translation = $node->getTranslation($langcode);
  } else {
    $node_translation = $node->addTranslation($langcode, $node->toArray());
  }

  $node_translation->status = 1;
  $node_translation->title = 'title en';
  $node_translation->subtitle = 'subtitle en';
  $node_translation->save();
}

And it crashes with a 500 error, reporting :

 - DrupalCoreEntityEntityStorageException : Invalid translation language (und) specified. dans DrupalCoreEntitySqlSqlContentEntityStorage->save() (ligne 805 de /.../web/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).
 - InvalidArgumentException : Invalid translation language (und) specified. dans DrupalCoreEntityContentEntityBase->getTranslation() (ligne 783 de /.../web/core/lib/Drupal/Core/Entity/ContentEntityBase.php).

I’m pulling my hair out on this issue for days and can not understand why the error message tells me $langcode equals 'und' whereas a var_dump of it just before this line returns me 'en'.


Edit :
I tried to hardcode and remove the foreach. So just after the $node->save() :

$node_translation = $node->addTranslation('en', $node->toArray());
$node_translation->set('title', 'title en');
$node_translation->set('field_sub_title', 'subtitle en');
$node_translation->save();

This time, the error is the following :

InvalidArgumentException : Invalid translation language (en) specified.
dans DrupalCoreEntityContentEntityBase->addTranslation() (ligne 863
de /var/www/drupalvm/drupal/web/core/lib/Drupal/Core/Entity/ContentEntityBase.php).


Get this bounty!!!

#StackBounty: #8 #migration Migrating references to items processed in the same migration

Bounty: 50

I’m trying to import data from custom source through Migrate in Drupal 8. The problem is that I need to process data which have references to each other. This is excerpt from my migration articles:

field_recommended_articles:
    -
      plugin: string_in_array
      key: id
      source: recommended_articles
    -
      plugin: migration_lookup
      migration: articles
      source: id

This seems to lead to recursion, because following error appears with stack trace containing repeating calls to respective migrate-related methods.

PHP Fatal error:  Maximum function nesting level of '2000' reached, aborting! in .../core/lib/Drupal/Core/Database/Statement.php on line 153

How can I solve this?


Get this bounty!!!

#StackBounty: #views #8 #google-maps Geofield Map – Filter attachment result by clicking marker

Bounty: 50

I’m facing a problem with geofield map and I can’t find a solution. So I have a view with a geofield map format. There I show all nodes from one node type as markers.
Under my map I have an attachment also with all nodes, but as a list with more details.

Now the problem: I want to filter the attachment when I click on a marker from the map. For example – I have 10 markers on my map. These 10 markers represent 10 nodes which are also shown in the attachment beneath. When I click on one marker on the map I want the attachment to show only one node in the results. It would also be great if the result would be updated via ajax.

enter image description here

I hope somebody can help me. 🙂


Get this bounty!!!

#StackBounty: #8 #migration How to migrate content using a web service with multiple calls?

Bounty: 50

I need to migrate content from a web service to which I have to call several URLs. A call to receive a list of nodes and then a call for each node to receive information from the fields.

Something like this:

Calling domain.test/webservice/

<results>
  <count>10</count>
  <list>
    <id>100</id>
    <id>101</id>
    <id>102</id>
    ...
  </list>
</results>

Calling domain.test/webservice/101

<results>
  <id>101</id>
  <name>Name</name>
  <field1>Field example</field1>
    ...
</results>

So, in my migration yml file I have something like:

source:
  plugin: url
  data_fetcher_plugin: http
  headers:
    Accept: application/xml
  data_parser_plugin: simple_xml
  urls: https://domain.test/webservice/

How can I specified the migrate process to retrieve each content info from a URL like https://domain.test/webservice/[ID]?


Get this bounty!!!