Drupal StackExchange

How to populate a node reference field that has multiple values?

1 month 3 weeks ago

I'm using the rules to create a new node upon changing the current node publishing status to published. And populate some field based on the updated node field. Im trying to populate a node reference field in the new created node based on the node reference field multiple values from updated node. I wasn't able to use the tokens since it returns single value. How do I get all the values using tokens and return the values in an array (using the php code)?

adez

Admin Search Report Data

1 month 3 weeks ago

On the /admin/reports/search report, there are the most searched terms listed. On the installation I'm responsible for since a few weeks, this list is emptied every day. This is one part of the problem, but my question is another, as I also have to create a detailed report on how the search was being used.

For that reason I'd like to export the data as it is shown on the /admin/reports/search page on a daily basis. Unfortunately the content of the database table "search_total" seems not to be the resource of the report. I looked into the Drupal Search Tables: https://www.drupal.org/node/2360879 but didn't manage to reproduce the contents of the report page.

Does anyone know how this data is curated and how I can export this data via mysql?

I'm using the default drupal search and Drupal v9.5.11.

Thanks in advance :)

macstens

CKEditor scayt Plugin module

1 month 3 weeks ago

I'm trying to build a scayt module to be able to use the CKEditor scayt Plugin. I tried to use this module but it did not work for me. https://github.com/nikhildodeja/scayt I created my own but I get a WSOD when I veiw a node creat page. The module is below. What am I doing wrong?

<?php /** * @file * Definition of \Drupal\scayt\Plugin\CKEditorPlugin\Scayt. */ namespace Drupal\scayt\Plugin\CKEditorPlugin; use Drupal\ckeditor\CKEditorPluginBase; use Drupal\editor\Entity\Editor; /** * Defines the "Scayt" plugin. * * @CKEditorPlugin( * id = "scayt", * label = @Translation("Scayt CKEditor") * ) */ class Scayt extends CKEditorPluginBase{ /** * Implements \Drupal\scayt\Plugin\CKEditorPluginInterface::getDependencies(). */ function getDependencies(Editor $editor) { return array('panelbutton','floatpanel','menu','menubutton','dialogui','button'); } /** * Implements \Drupal\scayt\Plugin\CKEditorPluginInterface::getLibraries(). */ function getLibraries(Editor $editor) { return array(); } /** * Implements \Drupal\scayt\Plugin\CKEditorPluginInterface::isInternal(). */ function isInternal() { return FALSE; } /** * Implements \Drupal\scayt\Plugin\CKEditorPluginInterface::getFile(). */ function getFile() { return 'libraries/scayt/plugin.js'; } /** * Implements \Drupal\scayt\Plugin\CKEditorPluginButtonsInterface::getButtons(). */ function getButtons() { return array( 'Scayt' => array( 'label' => t('Spell Check'), 'image' => 'libraries/scayt/icons/scayt.png', ), ); } /** * Implements \Drupal\scayt\Plugin\CKEditorPluginInterface::getConfig(). */ public function getConfig(Editor $editor) { return array(); } }
paul cappucci

How can I update webform_submission uid in the table, after which the anonymous user has registered?

1 month 3 weeks ago

I'm a graphic design, and I just started using Drupal 7.

I have a form created with webform, which collects data entered by the user, after sending, the user is directed to the purchase page. The stages of the purchase is successful if both the user and logged in, whether the user is anonymous.

Here's my problem, from the control panel of Drupal 7 when I go to see the results of the webform, if the form has been sent by the user logged in, see the user's name, is so I know who did it then submitting the form. While it has been the anonymous user, in the results I see anonymous user even after the user has registered and recognized.

For clarity I describe what it does with this form, these are the steps that the user to fill out the form webform:

1) Fill out the form webform (in this form there two fields of the form "webform commerce") 2) after sending the form you will be directed during the cart / checkout, at this stage the user enters the email for the registration, if it is anonymous. Everything works perfectly.

I noticed that the field in the table webform_submission uid inside the database remains at 0 even after the user has registered.

Browsing around the net in the blog / forum / drupal.org I left this tutorials: example tutorial so I'm starting to use hook_webform_submission_presave in a custom form. So how do I fill the uid after the form has been sent?

This is the code:

<?php /** * @file * Questo modulo server per collegare utente anonimo con il webform inviato. */ // hook per ottenere l'ID dell'utente che ha inviato il modulo webform function mio_modulo_webform_submission_presave($node, &$submission) { // Ottengo l'id dell'utente. //$user = user_load($submission->uid); global $user; $user->uid; } ?>

Sorry for my english Thanks in advance for the help

user3311699

Poll as "Rendered Entity" field is not displaying in views

1 month 3 weeks ago

I have integrated Poll as a field in Content type,let be "article'.Poll is displayed as rendered entity wherever required.

Now I have created a view listing all articles.Poll is also added and displayed as rendered entity.

When the poll field is called in Custom text.,Poll entity(form) is displayed in views preview,but not in Output page..In output no poll is displayed

Fatima

Fluch cache on all sites in multisite platform

1 month 3 weeks ago

Is there a way to clear cache on all sites in platform by using platform alias? For example, drush @platform_name cc all ? (its multisite setup via aegir).

The problem I am facing with is, when I run that command or the one with @sites, I get a message

Could not find a Drupal settings.php file at sites/default/settings.php.

So, I then copied default.settings.php as settings.php (which is by default fully commented out) in sites/default, and then it says

Drush was not able to start (bootstrap) the Drupal database.

Which is obvious, as default doesn't have database (Aegir creates all sites in platform as separately and never touches default).

I also tried to delete default folder but Drush is telling me it needs to have settings.php there (even after I cleared drush cache). Drush in question is 8.1.0.

milovan

How can I create multiple cropped Media images without re-uploading them?

1 month 3 weeks ago

Solutions that I've found allow to crop Media, type Image when I've uploaded an image, but the media entity is not yet created (on the "Add media" page).

I need to upload a large full image once (and use it in full format on some nodes), and then crop it differently when I select it in different content types (to display small "zoomed" parts of the full image). So I need a manual crop to appear when I select a Media of type Image from a Media library. It can appear in Entity browser or on the node page.

Other solution is that I can create cropped images in advance being in my media library (/admin/content/media) or when adding a media (/media/add/image). The idea is that I do not want to reupload the image and add new title and alt.

Is this possible?

Oksana

What is causing Unknown field error in EntityFieldQuery API?

1 month 3 weeks ago

I am attempting to use the entity-field-query API to see if any node of referee content type has custom field that equals x. I've looked at dozens of code examples and references. (Included below)

If it is relevant I am executing this code as a custom PHP action in Drupal rules.

My problem is when the code is executed I get the below error:

EntityFieldQueryException: Unknown field: field_referee_id‎ in EntityFieldQuery->addFieldCon dition() (line 817 of /home/scienceorg/public_html/includes/entity.inc).

(The field does exist on the referee content type.)

My code:

<?php error_reporting(E_ALL); $query = new EntityFieldQuery(); $query ->entityCondition('entity_type', 'node') ->entityCondition('bundle', 'referee') ->fieldCondition('field_referee_id‎', 'value', '1', '='); $result = $query->execute(); ?>

Further information: If I remove the field condition line from the above code it works perfectly. So the problems seems to be around finding the field_referee_id.

Code references and examples

EntityFieldQuery condition

https://www.drupal.org/node/1343708

Alternative answer: If you don't know what is causing the above problem I will accept alternative methods of achieving the same outcome as the correct answer.

sephiith

Change mark-up with a textfield using Ajax

1 month 3 weeks ago

In a form I have a field where the user have to enter the name, after this I have to update a markup with data from an external DB using the textfield as a parameter, How can I do this or even Is this posible?

PD: I am using autocomplete to show a list of users when the user is writing in the field. Thanks.

<?php /*this part is in hook_form_alter*/ $form['submitted']['empleado']['#ajax'] = array( 'callback' => 'ajax_saldo_markup_callback', 'wrapper' => 'saldo-markup-reload', ); $form['submitted']['saldo']['#prefix'] = '<div id="saldo-markup-reload">'; $form['submitted']['saldo']['#suffix'] = '</div>'; $form['submitted']['saldo']['#markup'] = _busqueda_saldo_vacas($form, $form_state); /*this part is in hook_form_alter*/ function ajax_saldo_markup_callback($form, $form_state) { return $form['submitted']['saldo']; } function _busqueda_saldo_vacas(&$form, $form_state){ $username = $form_state['values']['submitted']['empleado']; /*DB Query's*/ foreach ($result as $row) { //At the end I get only one data $form['submitted']['saldo']['#markup'] = $row->Data; } } ?>

With this code It seems to work, with Devel, the property "#markup" changes, but is not displayed, if I change it to "#title", it is displayed.

nano140795

Drupal Planet