Drupal StackExchange

Taxonomy Term showing strange text

17 hours 23 minutes ago

Having taxonamy term issues - as glossary terms showing with text below the text saying "There is currently no content classified with this term."

does anyone know how to remove or hide the statement mentioned?

Drupal 7

saraNPN

How to process a multiple values field (comma separated) in a Rules Action?

18 hours 21 minutes ago

I am using modules "SMS Framework",Clickatell for sending message and I have configured all the settings which was required. I have also created a rule where node (Article) be saved and send a message.

It is working good when I use single mobile number but unfortunately it is not working when I use multiple mobile number with comma separated.

Rahul Yadav

How do I enable a REST resource for a custom content type?

19 hours 19 minutes ago

I've created a bunch of custom content types like "Car Makes" and "Car Models", but I can't seem to figure out how to enable a REST resource for them. In my REST settings page, I see the default content, content type, user, user registration enabled and a lot of disabled types below it. This list doesn't contain any of my custom created types.

If I go to the permissions page, under "RESTful Web Services", I only see "Administer REST resource configuration" and "Access POST on User registration resource". How can I enable "Car Makes" as a REST resource and directly GET/POST with it?

I saw this screenshot, but I don't get anything like this in Drupal 8.4:

In this screenshot, Todo is a custom resource, which requires writing a plugin. Do I have to write a plugin module just to expose each of my custom content types in REST?

I can work directly with the content endpoints, i.e. POST /node/123, but I would like to POST /carmakes, for example.

aalaap

Create a View of Books

20 hours 21 minutes ago

I'm using the core Book module for organizing meeting notes and documentation. How do I create a list of books with the views module? That is, I'd like a list of only the top-level Books, not all the book pages.

An example of what I want in core is at admin/content/book which looks like this:

Thus far, all I've been able to get is a hierarchical list of books and all book pages. Current view:

rocketeerbkw

Adding HTML class attributes to Entity Reference field links in View

21 hours 21 minutes ago

I have a view ("Tasks") that pulls in Task nodes, complete with sorting and filtering. Each Task can have multiple nodes attached via the "Related Articles" field (field_related_articles). I am trying to loop through each node (which can be a Video, Document, Article, etc.) and assign each link a class name depending on the type.

For example, a "Document" node attached to a Task would display a hyperlink with the document class. Video nodes will be video, and so on.

Here is my preprocess that is targeting the specific field:

function mytheme_preprocess_field__node__field_related_articles(&$variables) { $items = $variables['items']; foreach ($items as $index => $item) { $content_type = $item['content']['#options']['entity']->type->entity->label(); $class_name = slugify($content_type); // custom function $variables['items'][$index]['attributes']['class'] = [$class_name]; } }

When I inspect the $variables array, I see the following, which looks okay to me (but I can't be sure):

As you can see, the attributes object now has a class value for each items value (I have two). However, in the HTML, the classes do not show up:

Is there something I'm doing wrong?

TerranRich

Migration lookup and no stubbing

22 hours 24 minutes ago

I have a problem with languages and no stubbing regarding migration_lookup plugin in Drupal 8. I have a different json data, each of them is different languages for example json with de:

data:{ id: 12345, name: 'Product 1 de', id: 123456, name: 'Product 2 de'}

json with en

data:{ id: 12345, name: 'Product 1 en'}

of course this json is only example not validate.

I have a 2 migration yaml file called: migrate_plus.migration.data.yml and migrate_plus.migration.data_de.yml

English version is default version in drupal.

To join de version with en I use process:

nid: - plugin: migration_lookup source: id migration: data no_stub: true stub_id: data

I use no_stub: true because i don't want to create stub nodes for not existing en version. Everything works well but only for first time but if I want to update migration I got errors

[error] Drupal\Core\Database\IntegrityConstraintViolationException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '9424706c-e536-4a59-be13-ebb91367a1a9' for key 'node_field__uuid__value': INSERT INTO {node} (vid, type, uuid, langcode) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3); Array

for de version item. In my case I don't want to create new stub item for english version for product 2 de so I though that no_stub option will be ok. Even if I do migrate:rollback I noticed that this migration from de still exist.

crafter

Why this code doesn't send an email with drupal_email()?

23 hours 18 minutes ago

I am developing a Drupal 6 module that should send an email after a form is submitted. So far, I wrote the following code.

function mailform_mail($key, &$message, $params) { $headers = array( 'MIME-Version' => '1.0', 'Content-Type' => 'text/html; charset=UTF-8; format=flowed', 'Content-Transfer-Encoding' => '8Bit', 'X-Mailer' => 'Drupal' ); foreach ($headers as $key => $value) { $message['headers'][$key] = $value; } $message['subject'] = $params['subject']; $message['body'] = $params['body']; } /** * Form submission handler. */ function mailform_form_submit($form, &$form_state) { $valid_email = $form_state['values']['email']; $subject = $form_state['values']['Subject']; $body = $form_state['values']['body']; $params = array( 'email'=> $valid_email, 'body' => $body, 'subject' => $subject, ); // The first argument of drupal_mail() function must match the first part of the hook_mail function. // Therefore the first argument is 'mailform_form' and the the mail hook is 'mailform_form_mail' // For more infoormation see: // - http://api.drupal.org/api/function/drupal_mail/6 // - http://api.drupal.org/api/function/hook_mail/6 if (drupal_mail('mailform','reply', $valid_email, language_default(), $params, $from, TRUE) { drupal_set_message('An email has been sent to ' . $valid_email); } else { drupal_set_message('There was an error sending your email'); } }

Using this code, I can get the values after a form is submitted, but the mail is not sent out.

Is there anything wrong with the code? The module machine name is mailform.

Rahman

How can I fix the "Predis\Client not found" error?

1 day ago

I have a project based on Drupal 7. I installed PHP 7.4, Redis, and php-redis on Ubuntu. I get a Class 'Predis\Client' not found error.

The values in the setting.php file for the module are the following.

$conf['redis_client_interface'] = 'Predis'; $conf['cache_backends'][] = 'sites/all/modules/redis/redis.autoload.inc'; $conf['cache_class_cache'] = 'Redis_Cache'; $conf['cache_class_cache_menu'] = 'Redis_Cache'; $conf['cache_class_cache_drupal_get_filename'] = 'Redis_Cache'; $conf['cache_class_cache_bootstrap'] = 'Redis_Cache'; $conf['cache_class_cache_path'] = 'Redis_Cache'; $conf['cache_class_cache_field'] = 'Redis_Cache'; $conf['cache_class_cache_views'] = 'Redis_Cache'; $conf['cache_class_cache_admin_menu'] = 'Redis_Cache'; $conf['lock_inc'] = 'sites/all/modules/redis/redis.lock.inc';

When I run drush cc the same error is show. For solving that, I re-installed Redis and php-redis, but that hasn't fixed the error.

mohammad nabipour

How to configure a Slideshow with thumbnails in modal window

1 day 1 hour ago

I have tried to get the following scenario to work, with no success. I have 3 images. They are displayed in thumbnail form, in the bottom of a div. A main, preferred image, is displayed in a larger size above the thumbnails. I need that, when clicking on the thumbnail, the main image will change. So, in the image included, if I click on the green image, the main image will change from red to green.

Also I need that when clicking on the larger image, a modal window will appear, with a Slideshow of all the images, starting from the one clicked.

I have managed to make it work very easily with PHP-Javascript alone (10 minutes of programming) but I am not able to do it with none of the following modules: Colorbox, FlexSlider, Lightbox2.

Even when launching a View with FlexSlider content using Lightbox2, it works but it takes ages to load the content, even if I have disabled all extra HTML stuff by making a template tpl suggestion.

Sincerely, I don't think it is so complicated behaviour. Also there is the approach of FlexSlider with thumbnails, but I cannot manage to include the lightbox (modal window) effect.

Cesar

Drupal Planet

Balint Pekker: Simplifying Drupal Documentation

20 hours 2 minutes ago
Are you new to the world of Drupal, eager to dive into its powerful capabilities, but encountering obstacles in the form of outdated tutorials and confusing documentation? You're not alone. Beginning your Drupal journey can feel like navigating uncharted territory, leaving many feeling frustrated before they even begin.