texts:
I'm using hook_views_query_alter() and am wondering where I can find the syntax for the various query modifiers.

One of the examples I found looked like this:

$query->orderby[0] = "FIELD(node.type, 'story', 'page', 'productTypeC', 'productTypeD') ASC";

I'm not sure what that syntax is saying. Does it mean order by the node.type field, where nodes with story are first, then page, and so on? Or something else? I need to be able to group on multiple fields (and not all fields are on the initial node (relationships.)

Is there somewhere that all of the available modifiers are documented, including their syntax? By modifiers, I mean $query->orderby, $query->where, and so on.


texts: Why would some backup schedules work and others not?

texts:
I have several backup schedules set up:

Every 15 minutes (keeping 12)
Every 8 hours (keeping 9)
Daily Backup (keeping 31)
Weekly Backup (keeping 52)
Yearly Backup (keeping 5)

The perplexing problem is that some of them seem to be working and some not, even though they're all using the default profile, and they're all enabled, and they're all being saved to the scheduled backups directory.

Here are the backups that are appearing:

sitename-2012-11-10T18-10-05 Sat, 11/10/2012 - 18:10 25 min  311.12 KB
sitename-2012-11-10T18-03-58 Sat, 11/10/2012 - 18:03 31 min  305.58 KB
sitename-2012-11-10T17-48-49 Sat, 11/10/2012 - 17:48 46 min  308.19 KB
sitename-2012-11-10T16-43-06 Sat, 11/10/2012 - 16:43 1 hour  303.99 KB
sitename-2012-11-10T16-43-05 Sat, 11/10/2012 - 16:43 1 hour  303.99 KB
sitename-2012-11-10T15-43-02 Sat, 11/10/2012 - 15:43 2 hours 304.01 KB
sitename-2012-11-10T14-43-00 Sat, 11/10/2012 - 14:43 3 hours 303.99 KB
sitename-2012-11-10T13-38-00 Sat, 11/10/2012 - 13:38 4 hours 303.95 KB
sitename-2012-11-10T12-33-00 Sat, 11/10/2012 - 12:33 6 hours 303.95 KB
sitename-2012-11-10T11-28-01 Sat, 11/10/2012 - 11:28 7 hours 303.94 KB
sitename-2012-11-10T10-23-00 Sat, 11/10/2012 - 10:23 8 hours 303.95 KB
sitename-2012-11-10T09-18-02 Sat, 11/10/2012 - 09:18 9 hours 303.94 KB

The fact that there are 12 (which is the number mentioned in one of the schedules) makes me think that perhaps the Backup & Restore module has a major bug: perhaps it assumes you'll only have one or two schedules, and my 5 overwhelmed it.

Is there any other reason for the behavior you're seeing?


texts: custom action plugin with ConfigurationForm

texts:
I am trying to create a custom action with Configuration Form Field . I am able to create Action and it is being displayed on content page ( /admin/content ) , but I am not able to find the path to configure the fields in the Action Plugin.Can anyone please let me know the path to configure the Action Plugin ?
My Code as follows :
UpdateNodeTitle.php
namespace Drupal\action_plugin_examples\Plugin\Action;

use Drupal\Core\Action\ConfigurableActionBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Session\AccountInterface;

/**
 * Provides a an Update node title action.
 *
 * @Action(
 *   id = "action_plugin_examples_update_node_title",
 *   label = @Translation("Update node title"),
 *   type = "node",
 *   category = @Translation("Custom")
 * )
 *
 */
class UpdateNodeTitle extends ConfigurableActionBase {

  /**
   * {@inheritdoc}
   */
  public function defaultConfiguration() {
    return ['title' => ''];
  }

  /**
   * {@inheritdoc}
   */
  public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
    $form['title'] = [
      '#title' => $this->t('New title'),
      '#type' => 'textfield',
      '#required' => TRUE,
      '#default_value' => $this->configuration['title'],
    ];
    return $form;
  }

  /**
   * {@inheritdoc}
   */
  public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
    $this->configuration['title'] = $form_state->getValue('title');
  }

  /**
   * {@inheritdoc}
   */
  public function access($node, AccountInterface $account = NULL, $return_as_object = FALSE) {
    /** @var \Drupal\node\NodeInterface $node */
    $access = $node->access('update', $account, TRUE)
      ->andIf($node->title->access('edit', $account, TRUE));
    return $return_as_object ? $access : $access->isAllowed();
  }

  /**
   * {@inheritdoc}
   */
  public function execute($node = NULL) {
    /** @var \Drupal\node\NodeInterface $node */
    $node->setTitle($this->configuration['title'])->save();
  }

}

action_plugin_examples.schema.yml
action_plugin_examples.configuration.action_plugin_examples_update_node_title:
  type: mapping
  label: 'Configuration for "Update node title" action'
  mapping:
    title:
      type: string
      label: Title

system.action.action_plugin_examples_update_node_title.yml
langcode: en
status: true
dependencies:
  enforced:
    module:
      - action_plugin_examples
  module:
    - node
    - pathauto
id: action_plugin_examples_update_node_title
label: 'Update Node Title'
type: node
plugin: action_plugin_examples_update_node_title
configuration: {  }

I have seen a similar Action Plugin in core as well but can not find the path to configure the Plugin. AssignOwnerNode
Another Contributed module with similar functionality custom pub


texts:
I need to debug $message on hook_mail_alter(&$message). In D7 it was pretty easy to dpm() on hook_mail_alter(). Now in D8 dpm() doesn't print the nicest output anymore.

I'ld like to see the possible methods I can use. So I'ld like to use kint()/ksm() but this seems to break the functionality of my site. I get a WOSD without Watchdog catching anything.

Did anyone else come across this issue? Do you have some tips how I can use Kint on hook_mail_alter() to print me useful output?


texts: user reference field as exposed filter in view makes it very slow

texts:
I am using user reference field as exposed filter. The problem is that, it makes view very slow. Actually, rendering time is one minute for 100 results per page. If i remove it from filter, it goes down to about few seconds.

What can i do about it?


texts: Is there a function to get the current user object that avoids accessing the global variable?

texts:
I've always gone with this global $user;. However, I seem to remember seeing something in a contributed module that returned the current user object without using the global $user.

Does such a function exist in Drupal 7 core, or is using the global variable the de-facto recommended way to get the current user object?


texts: How to delete all Persistent variables when a page is loaded?

texts:
I have many variables set through variable_set. Is there any other way to delete them all at once apart from variable_del?

or How can find all the persistent variables set in the module?


texts:
I installed Drupal 7 on Wamp Server. I can't find any checkbox or link to enable clean URLs; I see only the Run the Clean URL Test button.

How can I enable clean URLs?


texts:
Initially I wanted a list of Authors in an exposed filter (as a checkbox) but after looking into BEF (better exposed filters) it seems this isn't possible.

Instead I am trying to create a taxonomy term for each user created but have found regardless of what entity I am trying to create, the hook for insertion is never called.

I am using xdebug and was expecting at least a single breakpoint inside one of the functions to work but it never triggers, I have cleared my cache and other preprocessing functions inside this file (bare.theme).

A few examples of functions I have tried (my theme is called "bare"):

function bare_entity_insert(Drupal\Core\Entity\EntityInterface $entity){}

function bare_user_insert(\Drupal\user\UserInterface $user) {}

function bare_entity_create(Drupal\Core\Entity\EntityInterface $entity){}

function bare_user_create(\Drupal\user\Plugin\Core\Entity\User $user){

I feel I have missed something very crucial, perhaps I can't call these functions inside a .theme file?


texts: Disable plugin ckeditor per content type

texts:
I am using the ckeditor module.
I have 2 content types.
Both content types use the same ckeditor profile on their body field.

Is it possible, without creating another profile, to disable a certain plugin (e.g. image plugin) on that ckeditor profile for only one content type?


texts: Drupal::config to access Site default timezone

texts:
Like the title says, I want to access the sites default timezone.

Guess

Drupal::config('system.date')->get('timezone')['default']

is the right function.
I really would love to know how to use the config-function. Is there a list with all the configs, settings or variables that can be called?

Whats the logic behind the keywords "system.date"? Is there a way to discover keywords by looking at the yml config structure? Can all values of them be returned?


texts: Does the Services module implement caching on GET requests?

texts: Before I build a REST server with the Services module, I'd like to know if the responses to the GET requests are being cached? I searched Google and it seems that caching wasn't implemented, however, those articles are from 2011 and 2012.


texts:
I have a node.

This node is set to be the 'Default 404 (not found) page' in

  admin/config/system/site-information

I've got a custom block that I want to show within the node mentioned previous. I have used the 'restrict to certain pages' feature in configure block.

The problem is that it is not showing whenever I trigger a 404.

Can anyone offer a solution?

Thanks in advance.


texts: Commerce Kickstart is saving a transaction as both incompleted & successful

texts:
I have a site running Commerce Kickstart (Drupal 7.23, Kickstart 7.x-2.9)
I've noticed that some of the transactions are registered twice: one as not completed & the other one, as successful.
It's not so common, but it happens. I'm thinking that some users might have taken a long time to complete their order & Drupal registered it as checked out only (not completed yet), when they finally paid the order, it's was saved as a new order. I'm still not sure if this is the case or something else.
Has anyone experienced this issue & what have you done?


texts: URL paths in optimized CSS sometimes are https instead of http

texts:
The expanded URLs inside my optimized CSS files are sometimes getting generated with https instead of http.  This appears to happen randomly. Doing a cache clear, recreates the optimized CSS and usually the URLS are correctly expanded using http.

The source CSS files have relative paths in them, for example:

@font-face {
  font-family: "my-custom";
  src: url("../fonts/my-custom/my-custom_47f454dc1e054575ab6c2a63cbc17e46.eot");

In the optimized CSS this gets expanded to a full URL:

@font-face
{ font-family: "my-custom"; font-style: normal; font-weight: normal; src: url("http://i.cdn.my.com/drp/.../assets/fonts/my-custom/my-custom_47f454dc1e054575ab6c2a63cbc17e46.eot?#iefix") format("embedded-opentype"),

Then, seemly randonly it will be:

@font-face
{ font-family: "my-custom"; font-style: normal; font-weight: normal; src: url("https://i.cdn.my.com/drp/.../assets/fonts/my-custom/my-custom_47f454dc1e054575ab6c2a63cbc17e46.eot?#iefix") format("embedded-opentype"),

I have CDN enabled on the site, so that might be a factor.  But again why is the behavior seemingly random?

Any suggestions on where to start looking in settings, hooks that affect CSS optimization behavior, known bugs with CSS optimization, etc. would be appreciated.


texts: Can't get hostEntityId inside computed field code

texts:
This is for entity form submission.
 Entityform has field collection field which contains computed field and other text field.

Inside computed field I need hostEntityId(in this case id of Entityform), but hostEntityID() is returning empty or null. Code I tested

/*get wrapper to which current field is attached*/
$wrapper = entity_metadata_wrapper($entity_type, $entity);

//get the host entity to which field collection is attached.
$entityid = $entity->hostEntityId();
dpm($entityid);// returning empty

$host = $entity->hostEntity( );
dpm($host); // work ok but entityid is missing

$bundle= $entity->hostEntityBundle();
dpm($bundle);//works ok , returning custom entityform type that I created.

$entity_field[0]['value'] = "some more computation..";


texts: How to get achievements notification popup for Ajax Callbacks?

texts:
I'm using the Achievements module to award the badges to users on certain actions.

In the following example user will get badges after posting 5 and 10 comments.

function MYMODULE_comment_insert($comment) {
  $current_count = achievements_storage_get('comment-count', $comment->uid) + 1;
  achievements_storage_set('comment-count', $current_count, $comment->uid);

  foreach (array(5,10) as $count) {
    if ($current_count == $count) {
      achievements_unlocked('comment-count-' . $count, $comment->uid);
    }
  }
}

The above code is working, user is able to achieve badge after posting 5 comments but since the comment form is being submitted through AJAX, the rewarded achievements notification popup is not being shown until page refresh.

So how can I show achievement notification popup for Ajax callbacks? Any suggestions?


texts: Expose the required fields in listing view

texts:
I have created a content type say "Form" which have one of a field named as "gender" set as a radio buttons.
This radio button I want to expose or make it visible with its functionality when I am displaying it in a View which can be called as "Form display" on a listing page.
I hope my question was clear,if not then please ask me in comments.


texts: white-space and minimum length validation in custom search

texts:
I'm using custom search for my website. Now I wan't to validate user input before search like validate white-spaces (just enter space in search box and you'll find all things goes wrong).

For minimum length validation drupal take cares for minimum 3 character, but if you enter less then 3 characters and press search button search results page appears and then it shows an error that you need to enter keyword with 3 characters or more.

I don't want to go on search results page until all validation criteria passes. In this case I want just red border on search box (this is happen when no text inserted in the search box and you press search button).

How can I validate white-space, minimum search keyword length and restrict user on same page until all validation criteria passes in custom search module?


texts: What does a value of -1 mean when it's present in the expire field of a cache entry in the database?  I've honestly looked around and could not find an answer.


texts: Prevent a "default value" checkbox being created with entity?

texts:
I have a boolean field associated with my custom entity. The field itself is hidden in the entity form however when an instance of my entity is created a field record is generated with the default value. This is not the case for a text field i have, where if the field is hidden the field record is not created.

Basically this creation of a default boolean field is messing up my views further down the line.

How can i prevent a default value boolean field being autogenerated when hidden?

Thanks
Mathew


texts: How do I display a Taxonomy Term Description to a view in D7?

texts: I would also like to know how to display a custom field that you add to taxonomy terms.... D7


texts: Anonymous users skip comment approval but they shouldn't

texts:
In my drupal 8.6.1 news blog anonymous users can skip comment approval althouth permissions are set to not skip. I rebuilt the permissions but nothing changed.

Also in comments page I see that some anonymous users are linked to an anonymous user account with id = 0 !

My site is not hacked and I can't understand what is going on.

Check this image!

Is there a chance that my drupal 8.6.1 has this unexpected behavior because is running on server with php 5.6?

Thanks in advance


texts: How to hide "Log in or register to post comments" when I've already disabled displaying comments?

texts: I already disabled comments. How can I remove the "Log in or register to post comments" text at the bottom of articles or other content types?


texts: How to create groups and assign users to them?

texts:
I want to allow the administrator and manager roles to be able to create groups (for example different jobs within a company) and be able to assign users to the groups. I want this to be a one-to-many relationship so that user1 can be assigned to job1 and job2 (or no job) but user1 can't be assigned twice to the same job.

How would I go about starting this or what is a good module and/or resource to utilize?


texts: Does Apache Solr assign a weight to HTML tags?

texts: Would Solr consider HTML tags when it creates its indexes? Would <h1>, for example, be more important than <h2>, <p>?


texts: Missing bundle entity, entity type paragraphs_type from field_instance.yml file

texts:
I'm currently trying to migrate my D7 site to D8 and one of the things migrating is field_collections to paragraphs. I have a field_collection call "field_sidebar_callouts". I want to migrate that to paragraphs.
Everything is migrating correctly until it reaches to field_instance.yml file. It throws an error call this:

Missing bundle entity, entity type paragraphs_type, entity id r_callouts

Is the instance.yml file importing half the id? How come the entity id is only "r_callouts" and not "field_sidebar_callouts".
Did my field_instance.yml get auto-generated incorrectly?
Any help would be amazing!
Here's my instance file:
uuid: 295c39a9-1857-4d53-a342-92a16ae71223
langcode: en
status: true
dependencies: {  }
id: upgrade_d7_field_instance
class: Drupal\migrate_drupal\Plugin\migrate\FieldMigration
field_plugin_method: alterFieldInstanceMigration
cck_plugin_method: null
migration_tags:
 - 'Drupal 7'
 - Configuration
 migration_group: migrate_drupal_7
label: 'Field instance configuration'
source:
 plugin: d7_field_instance
 constants:
  status: true
process:
 type:
  -
  plugin: process_field
  source: type
  method: getFieldType
 entity_type:
  -
   plugin: get
   source: entity_type
  -
   plugin: static_map
   map:
    field_collection_item: paragraph
    paragraphs_item: paragraph
  bypass: true
field_name:
  -
   plugin: get
   source: field_name
bundle:
 -
  plugin: static_map
  source: bundle
  bypass: true
  map:
    comment_node_forum: comment_forum
-
  plugin: paragraphs_process_on_value
  source_value: entity_type
  expected_value: field_collection_item
  process:
    plugin: substr
    start: 6
label:
 -
  plugin: get
  source: label
description:
 -
  plugin: get
  source: description
required:
 -
  plugin: get
  source: required
status:
 -
  plugin: get
  source: constants/status
allowed_values:
 -
  plugin: sub_process
  source: allowed_vid
  process:
    -
      plugin: migration_lookup
      migration: upgrade_d7_taxonomy_vocabulary
      source: vid
settings:
  0:
   plugin: d7_field_instance_settings
   source:
    - settings
    - widget
    - field_definition
field_collection:
  plugin: field_collection_field_instance_settings
default_value_function:
 -
  plugin: get
  source: ''
default_value:
 -
  plugin: d7_field_instance_defaults
  source:
    - default_value
    - widget
translatable:
 -
  plugin: get
  source: translatable
settings/title:
 -
  plugin: static_map
  source: settings/title
  bypass: true
  map:
    disabled: 0
    optional: 1
    required: 2
destination:
 plugin: 'entity:field_config'
migration_dependencies:
 required:
  - upgrade_d7_field
optional:
  - upgrade_d7_node_type
  - upgrade_d7_comment_type
  - upgrade_d7_taxonomy_vocabulary
  - upgrade_d7_field_collection_type


texts: Programmatically create new Schedule Updates Entity Reference on Node

texts:
I’m attempting to populate an entity referenced field created by the Scheduled Updates module within a content type, Event. Within Event I have two Scheduled Updates fields to check and uncheck the Sticky at top of list option.

I also have a product, Promote Event, in which the user is required to add a Begin Promoting Date, an Entity Reference to an Event, and a Quantity. Once a user purchases the Promote Event, I’d like to populate the Scheduled Updates fields within the Event content type with the data used in the purchase.

I can’t seem to figure out how to programmatically populate the Scheduled Update fields within the Event content type after the purchase of Promote Event.

Within my custom module I have:

public function orderCompleteHandler(WorkflowTransitionEvent $event) {
  /** @var \Drupal\commerce_order\Entity\OrderInterface $order */
  $order = $event->getEntity();

  // Order items in the cart.
  $items = $order->getItems();
  if($order->bundle() == 'promoted_event'){
    $beginPromo = $items[0]->get('field_begin_promotion')->getValue();
    $beginPromo = $beginPromo[0]['value'];
    $quantity = $items[0]->get('quantity')->getValue();
    $quantity = str_replace('.00', '', $quantity[0]['value']);
    $eventId = $items[0]->get('field_event_to_promote')->getValue();
    $eventId = $eventId[0]['target_id'];
    $endPromo = date('Y-m-d', strtotime($beginPromo. ' + '. $quantity .' days'));

    $node = Node::load($eventId);
    // Get the promote_event Entity Reference
    $promoteEvent = $node->get('promote_event')->first();
    // Get unPromoteEvent
    $unPromoteEvent = $node->get('unpromote_event_')->first();
    if($promoteEvent){

    } else {
      $dateTime = new DrupalDateTime($beginPromo, 'UTC');
      $timestamp = $dateTime->getTimestamp();
      $node->promote_event[] = [
        'user_id' => 1,
         'type' => 'node__sticky',
         'update_timestamp' => $timestamp
       ];
       $node->save();
     }
   }
 }


texts: Drupal 8: make Taxonomy terms translatable

texts:
How to translate Taxonomy terms?
I have 2 languages in my site added here: /admin/config/regional/language
I have turned the Types here /admin/structure/types marked "Show language selector on create and edit pages" in "Language settings" of each type.
But I cannot really understand what to do in Vocabulary settings?
I have terms but I cannot see button "Translate" that it was in Drupal 7.
Should I create 2 languages terms separately one from another?
Please give me manual.


texts:
We want to move all files to amazon s3 storage and I'm wondering if it is enough to move sites/default/files to a new storage.

I know there are modules which offer Amazon S3 support, but I would like to try a low level solution by mounting the new storage as the files directory and let the OS do the job.

Has anyone tried this before or should I just use AmazonS3 or Storage API modules? Thanks


texts: How to determine block module given block delta

texts:
Is there a way to determine a block's module given only the block's delta? I'm hoping for a solution that does not require a custom query.

Use case:
We are enabling our client to decide which blocks are displayed on a given content type. Those options include blocks created through the block admin interface and blocks created through the views admin. From what I can tell, a regular block and a view's block are rendered differently so psuedo code would be something like.

// In preprocessing
if($block_module === 'views') {
    // do view rendering
} else {
    // do normal block rendering
}

Any ideas?


texts:
For some reason, ctools/includes/plugins.inc is requiring an .inc file that doesn’t exist (and doesn’t need to exist in this custom module, as far as I know), and on /admin/user/permissions, that’s what it’s blaming for the 500 error. Other admin pages are fine. This is also making drush throw a lot of errors on drush cc all.

Error in dblog and syslog:

  require_once(./sites/SITENAME/modules/CUSTOM/MODULENAME/SundialParser.inc) [function.require-once]: failed to open stream: No such file or directory in D:\PATH\acquia-drupal-1.2.21\sites\SITENAME\modules\ctools\includes\plugins.inc on line 770.

PHP 5.2.17
PHP memory limit 256MB
Ctools 6.x-1.12

Stuff I’ve tried that hasn’t worked:

adding and enabling the filter permissions module
changing the admin theme
increasing php memory
manually truncating cache tables

Existing discussions:

Error 500 only on permissions page
https://www.drupal.org/node/1775612 (this is for D7 but seems like the same problem)


texts:
I need to create a web page in Drupal 6. The site has multiple PHP pages under different themes. For example, inside opt/mycompanyWeb/web/sites/all/themes/custom/MyCompanyInterior there are a bunch of pages such as page-node-50.tpl.php and page-node-608.tpl.php.

I have figured out to create a static page via the Add content menu, but I haven't figured out how to get Drupal to display a page I create in that directory. Any idea on how to do this?


texts: OutboundPathProcessor is not appending $options array?

texts:
I have a simple OutboundPathProcessor that should append a query string and a URL fragment, but nothing is happening.

mymodule.services.yml

services:
  mymodule.path_processor:
    class: Drupal\mymodule\PathProcessor\MyModulePathProcessor
    tags:
      - { name: path_processor_outbound }

MyModulePathProcessor.php

namespace Drupal\mymodule\PathProcessor;

use Drupal\Core\PathProcessor\OutboundPathProcessorInterface;
use Drupal\Core\Render\BubbleableMetadata;
use Symfony\Component\HttpFoundation\Request;

class MyModulePathProcessor implements OutboundPathProcessorInterface {

  function processOutbound($path, &$options = array(), Request $request = NULL, BubbleableMetadata $bubbleable_metadata = NULL) {

    $options['query']['foo'] = 'bar';
    $options['fragment'] = 'baz';

    return $path;
  }

}

It seems the $options array is passed by reference, and in fact LanguageNegotiationUrl::processOutbound is placing multiple values in the $options array.

Why doesn't my code work?

I just figured out that it does work if I add a URL prefix using $options['prefix'] = 'prefix/';, so some options are getting applied.
Why aren't fragment and query used?


texts:
I have a simple contributed module that I have written. It has pretty basic javascript. I decided to clean it up and write it in vanilla js, removing jQuery since that seems to be the direction we're going. Here is the resulting code...

const viewSourceLinks = document.querySelectorAll(
  '.simple-styleguide--view-sourecode'
);

[].forEach.call(viewSourceLinks, el => {
  el.addEventListener('click', () => {
    el.nextElementSibling.classList.toggle('active');
  });
});

const calculableElements = document.querySelectorAll('.calculate');

[].forEach.call(calculableElements, el => {
  const measuredElement = el.querySelector('.measure');
  const info = el.querySelector('.info');
  const lineHeight = `line-height: ${
    window.getComputedStyle(measuredElement).lineHeight
  }`;
  const fontSize = `font-size: ${
    window.getComputedStyle(measuredElement).fontSize
  }`;
  const margins = `margin: ${
    window.getComputedStyle(measuredElement).marginBottom
  }
        ${window.getComputedStyle(measuredElement).marginRight} ${
    window.getComputedStyle(measuredElement).marginBottom
  } ${window.getComputedStyle(measuredElement).marginLeft}`;

  info.innerHTML = `${fontSize}<br/>${lineHeight}<br/>${margins}`;
});

My question is, is this ok? Is this good enough to include as is? In general, it seems the advice is to always add your javascript within attached behaviors.

However, once I go down that road, I'm pretty much having to include jQuery in the wrapper. And I would much rather just have vanilla javascript.

The resulting code with behaviors ends up being something like this...

(($, Drupal) => {
  Drupal.behaviors.simpleStyleguide = {
    attach(context) {

      const viewSourceLinks = context.querySelectorAll(
        '.simple-styleguide--view-sourecode'
      );

      [].forEach.call(viewSourceLinks, el => {
        el.addEventListener('click', () => {
          el.nextElementSibling.classList.toggle('active');
        });
      });

      const calculableElements = context.querySelectorAll('.calculate');

      [].forEach.call(calculableElements, el => {
        const measuredElement = el.querySelector('.measure');
        const info = el.querySelector('.info');
        const lineHeight = `line-height: ${
          window.getComputedStyle(measuredElement).lineHeight
        }`;
        const fontSize = `font-size: ${
          window.getComputedStyle(measuredElement).fontSize
        }`;
        const margins = `margin: ${
          window.getComputedStyle(measuredElement).marginBottom
        }
              ${window.getComputedStyle(measuredElement).marginRight} ${
          window.getComputedStyle(measuredElement).marginBottom
        } ${window.getComputedStyle(measuredElement).marginLeft}`;

        info.innerHTML = `${fontSize}<br/>${lineHeight}<br/>${margins}`;
      });

    },
  };
})(jQuery, Drupal);

I've also read that if you have BigPipe enabled, you have to include jQuery. Not sure if that's true or not.

The vanilla js code above seems to be working. I just want to know that I'm doing this right, and that I'm not violating some Drupal standard by not wrapping it in a behavior.

Note: I should mention there is no ajax behavior in this module. If there were, perhaps I would have to use behaviors and context.


texts:
I am creating an Angular application using headless Drupal. I am using Drupal services module for web services.

I am trying to implement login mechanism in this app. Login is working fine but to handle authenticated requests, it is necessary to use "Cookie" header in each service call.

My app doesn't allow to use cookie header. In my browser console it says as

"Cookie unsafe header is not allowed". Is there any other way to fix this?


texts:
I am working on a website which has around 150k users.
I have to create a csv file which contains the details of user (drupal fields and profile2 fields ) and export the csv to another server daily.

I have implemented by export function in a hook_cron and in the function i do a user_load function call and two profile2_load_by_user and some other custom mysql queries.

The problem which i have is that my export_function does not seem to terminate, it may be a timeout or a memory problem.

I have tested my function my limiting the number of users to around 1000 and it works fine.

I am wondering whether it is possible to export huge volume of data through hook_cron.


texts: How to open file in new tab instead of download when submitting form?

texts:
The code below downloads the current file, I need it to open the file in a new tab, what needs to be added in order to do so?

public function submitForm(array &$form, FormStateInterface $form_state) {
     $filename = '/var/www/html/web/modules/custom/custom_module/sample.pdf';
     $response = new BinaryFileResponse($filename);
     $response->setContentDisposition(
          ResponseHeaderBag::DISPOSITION_ATTACHMENT,
          'sample.pdf'
     );
     $form_state->setResponse($response);


texts: How do I update multiple rows in one single function call?

texts:
I want to update multiple rows in one query, for example as with the following code.

db_query("update bestsellers set count = 4 where product_id = 30; update bestsellers set count = 5 where product_id = 32; update bestsellers set count = 1 where product_id = 34;")->execute();

The server returns a 500 error. Is there any way to achieve this?


texts: How can i access node_load () in my php page

texts:
I created a PHP page within my project and I am using node_load() to print data.

I also used these includes in my php page:

include 'modules/node/node.module';
include 'includes/common.inc';

But I get an error about an undefined function, like so:

  Call to undefined function cache_get() in
  D:\xampp-portable\htdocs\d6\includes\common.inc on line 3321"

So how can I access the 'node load' function in my page?


texts: Ajax InvokeCommand with custom Callback Primary tabs View(active tab)

texts:
I tried to do a what described in https://api.drupal.org/comment/56868#comment-56868, but for Drupal 8.

Drupal.behaviors.corsFileAutoUpload = {
  attach: function (context) {
    $(context).find('input[type="file"].s3fs-cors-upload').once('auto-s3file-upload').on('uploadToS3', Drupal.s3fs_cors.uploadToS3);
    },
}

To invoke this from PHP, I used the following code.

$response->addCommand(new InvokeCommand($selector, 'uploadToS3');

But I got an error from core/misc/ajax.js line number of 1266, as the method for the element is not available. On inspecting eventlistener in Chrome, it was very well visible and I was also able to fire it from Browser Console.
I am missing something here. How do we call a custom jQuery function using InvokeCommand?


texts: Data is shown multiple times when sorted in views

texts:
I'm using the module BibCite that provides a content type for managing bibliography. I want to show a list of all publications with Views. I'm using the fields mode and the citation field. The citation field is created by a BibCite engine that merges fields like author, title, publication year, etc. into one field. The problem is, when I want to sort them by author each publication is shown as many times as the number of authors it has. So a publication with with three authors is shown three times. I already tried the distinct query option and many variations of the aggregation option, but either too much is sorted out or there is an SQL error. How can I sort all publications by the last name of the first author?
EDIT: When I output only the author field it is a merged prename+name field. So maybe it is not even possible to sort by last name?
This is the SQL request:
SELECT bibcite_reference.langcode AS bibcite_reference_langcode, bibcite_reference.bibcite_year AS bibcite_reference_bibcite_year, bibcite_reference__author.author_target_id AS bibcite_reference__author_author_target_id, bibcite_reference.id AS id
FROM
{bibcite_reference} bibcite_reference
LEFT JOIN {bibcite_reference__field_dia_autor} bibcite_reference__field_dia_autor ON bibcite_reference.id = bibcite_reference__field_dia_autor.entity_id AND bibcite_reference__field_dia_autor.deleted = '0'
LEFT JOIN {bibcite_reference__author} bibcite_reference__author ON bibcite_reference.id = bibcite_reference__author.entity_id AND bibcite_reference__author.deleted = '0'
WHERE (bibcite_reference__field_dia_autor.field_dia_autor_target_id = 'de')
ORDER BY bibcite_reference_bibcite_year DESC, bibcite_reference__author_author_target_id ASC
LIMIT 50 OFFSET 0


texts: How do i disable cache on a webform block?

texts:
I've got site built in drupal 9 with a standard drupal custom block with a webform field in it. The webfrom is displaying some variables using computed twig fields on a commerce order information page. It's using fields extracted from the order to do the calculations and it works perfectly when logged in, but as an anonymous user it does not update when I go back and change the contents of the cart. I think it could be a webform problem or a drupal core problem, but is quite possibly a me-problem.
I have tried disabling the internal page cache, the internal dynamic page cache, and big pipe. I've tried using the cacheexclude module and cache_control_override but both appeared to be red herrings.
I've tried using this snippet in my theme-settings.php file (replacing webform_id with the id found on the rendered form with all the - in the id changed to _):
function fest_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
  if ($form_id == "webform_id") {
    //disable the form cache for anonymous users and all others too
    \Drupal::service('page_cache_kill_switch')->trigger();
  }
}

So far nothing has worked. My temporary solution is to put a reset button on the form - this works, but is not what my client wants, and I understand that.
I am not a coder so writing a module to do this feels a bit out of my league.


texts: Subtheme's newly created CSS files aren't working

texts:
I'm currently using Zen for my subtheme, and attempting to add CSS to my .info file, but all my effort is for naught. The .info file is in my subtheme's root, and is named as such - mytheme.info. When I add a css file I input the following code

 stylesheets[all][] = css/background.css

The css file is in the css folder of my subtheme's directory. The particularly annoying thing is if I input the same code into a pre-existing css file it works perfectly fine, for example I input:

  /* HTML Background-Image */
html{
background-image: url(../../images/body-bg.jpg);
background-repeat: repeat;
background-position: center center;

Into components/misc.css and it loads up perfectly fine, background and all.
I've read that using SASS might fix this problem, but I have a feeling that won't be the case

Am I doomed, never to create a new stylesheet and use it via the .info file, is anyone else experiencing this atrocity? Help Please :C


texts: Right way to create Yes/No boolean fields

texts:
I want to add fields in my node which will contain boolean values only : Yes/No. Selecting boolean as field type will cause the field to show up as single check box and in the node edit form I've difficulty in locating boolean type field.

Currently I'm using List(Text) and giving values as 1|Yes & 0|No.

What is the right way to use boolean values?


texts: How do I automatically remove spaces from a path in the blog module

texts:
Some places on the site are correct
e.g.  http://groundhogresearch.com/blogs/bob-schweickert-jr
but the blog module block show this path
http://groundhogresearch.com/blogs/Bob%20Schweickert%20Jr. which of course can't be found


texts: Cart order total summary vat calculation issue

texts:
When you have items in your cart and the shipping price is available, there is an issue with the order total summary:
Subtotal: 62,00 €
Shipping: 15,00 €
VAT: 10,76 €
Total: 77,00 €
The VAT is calculated on the 'subtotal'. That is not clear, if the 'shipping cost' appears before the 'VAT'. Or we need to switch both, or we need to calculate the VAT based on both 'subtotal' AND 'shipping'.
This looks more logic to me:
Subtotal: 62,00 €
VAT (21%): 10,76 €
Shipping (incl. VAT 21%): 15,00 €
Total: 77,00 €
OR recalculate VAT:
Subtotal: 62,00 €
Shipping: 15,00 €
VAT (21%): 13,36 €
Total: 77,00 €
Solution?
EDIT 1:
I've created a custom module and added the YML file there. mymodule.commerce_adjustment_types.yml. That is working.


texts: How to display node add answer form on a question page using the Answers module?

texts:
I want to set up my own Q&A site. I've installed the Answers module. It has satisfied me mostly, but not entirely. I need to place an answer node add form on the question page. I have no idea how to do this. I tried hooks from dru.io/quieston but my hook does not work.

I tried Advanced form block and it is ok: it displays node add form in question page but answers need to have a relationship to their question. When I add an answer on a page /node/add/answer it does not allow me to add an answer without question id.

So to place an answer, the relative path should be like this: /node/add/answer/117 - where 117 is the node id of the related question. And when I create answer using an Advanced form block form, it really adds  a new node, but such answer is not displaying in the question page and has an empty body. Because of question id should be defined.

How to display node add form in other node page with entity reference? And to define question id for this form?


texts: The test:run command is missing, but other commands work fine

texts:
I installed Drupal Console, put it on my path, ran drupal init, and  successfully used Drupal Console to generate a module.

Now I want to run tests with drupal test:run, but I get this error.

  [ERROR] Command "test:run", is not a valid command name.

drupal lists many commands, but it is missing the ones for tests. This is a sample of the list.

 state
  state:delete (std)                      Delete State
  state:override (sto)                    Override a State key.
 taxonomy
  taxonomy:term:delete (ttd)              Delete taxonomy terms from a vocabulary
 theme
  theme:download (thd)                    Download theme in application
  theme:install (thi)                     Install theme or themes in the application
  theme:path (thp)                        Returns the relative path to the theme (or absolute path)
  theme:uninstall (thu)                   Uninstall theme or themes in the application
 update
  update:entities (upe)                   Applying Entity Updates
  update:execute (upex,updb)              Execute a specific Update N function in a module, or execute all
 user
  user:create (uc)                        Create users for the application
  user:delete (ud)                        Delete users from the application

Why are the commands for tests missing?


texts: Is it possible to serve a theme from outside the web root?

texts:
We have a need to keep a proprietary theme in a directory that isn't readable or writable by a client.

At the same time, the client needs to be able to do standard Drupal updates (ie, they will have full control of the web root of the Drupal installation, but nothing above that).

What's the easiest/best way to accomplish this, assuming it's possible?


texts: Refresh two views with same exposed filter using ajax

texts:
I have a site with a map and a grid in the same page and they both have exposed filters enabled, yet I only have the exposed filter of the grid visible at the page. When the grid view is not using ajax, when the page refreshes all works well, yet I would like to use ajax to update the map and the grid with filtered results at the same time to improve the user experience.

Things that I have tried and that I have already discarded:
- Views Global Filter: I've tried this approach but it is kind of a mess since I have many fields to filter and sort with, and custom search preferences that I store in a session preferences key. And when I used it i had the impression that it was not possible to use with sorting preferences.
- views_embed_view: I've read that this may be the solution in some posts, but I don't understand yet what this call does and my site has a complex layout and I just cannot embed one view after another.
- Other stuff in a custom exposed filters submit function.

Ideally the solution would be to call an ajax refresh function from the custom submit function or to trigger it with javascript, when the update of the grid is triggered, it would be simple since the grid and the amp use the same arguments.

What I have thought what could be a hacky solution is to add the second exposed filter, to hide it with display:none, and then fill it with javascript and trigger the submit event whenever the visible filter of the grid is triggered. Nevertheless, if someone with proper expertise in Drupal can give me hint of how this should be properly accomplished it would be great!


texts: Using join query / checking conditions with a table without unique key

texts:
User fields are:

  field_age (text field)
  field_sex (text field)
  field_vaccinations_taken (node reference field with multiple values, referenced to vaccination content type)

Vaccination content type's fields are:

 field_age_lower
 field_age_upper
 field_for_sex

Previously I had to list users with certain age group and certain sex who were eligible for a particular vaccination. I was using these queries:

$query = db_select('field_data_field_age', 'a');

$query->join('field_data_field_sex', 's', 'a.entity_id = s.entity_id');
$query->join('users', 'u', 's.entity_id = u.uid');
$query->groupBy('a.entity_id');
$query->fields('u', array('mail'));

    if($sex == "Both"){
    $query->fields('s', array('field_sex_value'));
 }
    else {
    $query->fields('s', array('field_sex_value'))->condition('field_sex_value', $sex,'=');
}

 $query->fields('a', array('field_age_value','entity_id'))
  ->condition('field_age_value', $age_lower,'>=')
  ->condition('field_age_value', $age_upper,'<=');
$result = $query->execute();

This worked fine as the query->join worked good.

But now I need to check one more condition: If user has already taken the vaccination.

since the column entity_id has repeating values in the  table field_data_field_vaccinations_taken, I could not use $query->join to join the table . As seen in the table, there are multiple entries for 16, 17 and so on.

Is it still possible to join the table ? If yes, how can I check if the nid exists in field_vaccinations_taken  which is a node reference field?

If no, what would be the alternate to achieve this ?

I am new to using queries in drupal. So please forgive if I am going wrong way or missing something.

Would be grateful for any corrections/suggestions.
Thank you.


texts: Drupal 6.37 to 8.2.x upgrade with drush fails with 1115 Unknown character set: 'utf8mb4'

texts:
I am upgrading a legacy Drupal 6.37 site running on mysql 5.1 to a fresh install of Drupal 8.2.1 with mysql 5.7.16 on a remote host.  I have installed the migration modules required for drush and am able to execute the following:

drush migrate-upgrade
--legacy-db-url=mysql://root:XXXXXXXXXX@172.172.172.172/drupal_db
--legacy-root=http://www.currentsite.com --configure-only

but I am getting this error:

SQLSTATE[42000]: Syntax error or access violation: 1115 Unknown character set: 'utf8mb4'

I am aware of the '_dsn_utf8_fallback' => TRUE, connection setting and have included that parameter in my connection section of settings.php on the new host, but I am still getting the same error.


texts: Custom Line Item Loses commerce_unit_price and commerce_total

texts:
I'm working on commerce_layaway and running into an issue with my custom line_items. I've been using the commerce_shipping module as a base to work from.

I've added a new checkout page and pane. The current sequence of events is - Review cart, Shipping/Billing Information, Select Layaway option, Select Shipping option, Credit card information, Review, submit transaction.

When I select the layaway option I want to use, the commerce_line_item of type 'layaway' is created and has the commerce_unit_price and commerce_total price. At this point the line_item has been saved (which is why we have the commerce_total price on the line item). Moving on to the next step.

During the submission of the shipping pane form the following error occurs.

EntityMetadataWrapperException: Unable to get the data property currency_code
as the parent data structure is not set. in EntityStructureWrapper->getPropertyValue()
(line 442 of /var/aegir/platforms/commerce-7.x-1.3/profiles/worxco/modules/
secondary/entity/includes/entity.wrapper.inc).

This occurs because when the commerce_order_calculate_total($order) function is called it loads up the order_wrapper and loops through each line item. It gets the pricing of the commerce_total and for some reason when it gets to my custom commerce_line_item of type 'layaway' the commerce_total and commerce_unit_price and no longer there. So the error from above is thrown because the currency_code can not be retrieved from the non-existing commerce_total.

Is there something special I'm supposed to do in order to retrieve my commerce_unit_price and commerce_total for my line_item? I've debugged the code and don't see where the shipping is loading extra data and yet it still has it's commerce_unit_price and commerce_total.


texts:
Can you tell the meaning of form_build_id

I am trying to solve problem "add to cart form breaks after using Exposed filter with Ajax"

As I investigated, only form_build_id value changes when we are trying to search product catalog for certain products with Exposed Filters.

If I take initial form_build_id value for product's add to cart form, search catalog with Exposed Filter, than substitute via Firebug new form_build_id value with initial, and the form works


texts: How do you add remote javascript script with custom parameters?

texts:
There are many tutorials on adding js to themes in Drupal 7, but the examples for Omega Sub Themes seem to omit the part about remote scripts, scope and weight:

In the theme .info file:

scripts[] = js/map.js

So how do I specify remote URL, header or footer, and what weight to assign?

scripts[] = https://maps.googleapis.com/maps/api/js?key=XXX&sensor=false

results in <script src="&amp;muqqwd"></script> and even if it did work, I still need it to be in the header.


texts: Doing a global OR with the db abstraction layer

texts:
I have a function that makes a db query using db_select. The problem I'm having is that in a function elsewhere, the query object is applied a couple of conditions, and I want to add an OR clause but the final query ends with an AND instead of an OR.

Simplified example:

function a() {
    $q = db_select('table', 't');
    $q->addField('t', 'field1');
    b($q);
    // Here I want to add an OR so that the query
    // Selects the conditions applied in b()
    // or something else
    $q->execute();
}

function b($q) {
    $q->condition('t.field1', 'some val', '=');
    $q->condition('t.field2', 'some val', '=');
}

The way this example is, it would compile to something like

SELECT field1 FROM table AS t WHERE t.field1 = 'some val' AND t.field2 = 'some val'

I want to make it so that it compiles to

SELECT field1 FROM table AS t WHERE t.field1 = 'some val' AND t.field2 = 'some val' OR t.field3 = 'some val';

And the OR should be added in place of my comment in a(). How would I go about that in a proper way?

Right now I'm solving it with

$q->where(' 1 = 1) OR (t.field3 = :v', array(':v' => 'some val'));

which compiles to:

SELECT field1 FROM table AS t WHERE t.field1 = 'some val' AND t.field2 = 'some val' AND (1 = 1) OR t.field3 = 'some val';

but I feel that is just ugly, not to mention potentially buggy.

Using db_or instead of the line above results in this:

SELECT field1 FROM table AS t WHERE t.field1 = 'some val' AND t.field2 = 'some val' AND (field1 = 'some val');

That because the db_or crease some sort of combo, and you have to add more than one condition:

$or = db_or()->condition(...);
$or->condition(...);

Finally, it would be great to go a step further and create a query like

SELECT field1 FROM table AS t WHERE (... AND ...) OR ...

Edit: The example here is very simple, compared to the actual code, and I can't really modify the b function. I need to do the OR right where the comment is in a()


texts: Router can't find route in LanguageNegotiation plugin route name

texts:
I'm having to write a new LanguageNegotiation plugin for an API because the language is not the first part of the URL (it's the third). But D8 refuses to recognise the route to the plugin for the config menu item.

I have been following the Language module itself as a model and there is no other mention of an equivalent route name for any of the other LanguageNegotiation plugins. I have tried replacing 'doublespeak' with 'language' in the route name (no change).

Symfony\Component\Routing\Exception\RouteNotFoundException: Route "doublespeak.negotiation_api_url" does not exist. in Drupal\Core\Routing\RouteProvider->getRouteByName()

So the doublespeak.routing.yml looks like this:

doublespeak.negotiation_api_url:
  path: '/admin/config/regional/language/detection/apiurl'
  defaults:
    _form: 'Drupal\doublespeak\Form\NegotiationApiUrlForm'
    _title: 'API URL language detection configuration'
  requirements:
    _permission: 'administer languages'

And the start of the plugin is this:

namespace Drupal\doublespeak\Plugin\LanguageNegotiation;

use Drupal\Core\Language\LanguageInterface;
use Drupal\Core\PathProcessor\InboundPathProcessorInterface;
use Drupal\Core\PathProcessor\OutboundPathProcessorInterface;
use Drupal\Core\Render\BubbleableMetadata;
use Drupal\Core\Url;
use Drupal\language\LanguageNegotiationMethodBase;
use Drupal\language\LanguageSwitcherInterface;
use Symfony\Component\HttpFoundation\Request;

/**
 * Class for identifying language in an API URL via an infix value.
 *
 * @LanguageNegotiation(
 *   id = \Drupal\doublespeak\Plugin\LanguageNegotiation\LanguageNegotiationApiUrl::METHOD_ID,
 *   types = {\Drupal\Core\Language\LanguageInterface::TYPE_INTERFACE,
 *   \Drupal\Core\Language\LanguageInterface::TYPE_CONTENT,
 *   \Drupal\Core\Language\LanguageInterface::TYPE_URL},
 *   weight = -10,
 *   name = @Translation("API URL"),
 *   description = @Translation("Language from an API URL (/api/<channel>/<market-language>/refdata/<>)."),
 *   config_route_name = "doublespeak.negotiation_api_url"
 * )
 */
class LanguageNegotiationApiUrl extends LanguageNegotiationMethodBase implements InboundPathProcessorInterface, OutboundPathProcessorInterface, LanguageSwitcherInterface {

I've tried all sorts of options but can't make it work, and yes, I've cleared caches :-)


texts: Get the t function to work in a custom php file

texts:
I am having a custom hand coded PHP page within a Drupal module that loads in a fancybox.
I want the Drupal t() function to work in it. What should I include in the file to make it function?


texts:
I've installed JenkinsCI on our dev server to start automating our dev build and test process.   I'm using Jenkins with the Git Plugin and some Drush commands via a shell script.

When researching how to use Jenkins in my Drupal dev workflow, I came across a post about using Phing with Drush and Jenkins. So I looked at Phing and I can't see what it does that cannot be done by using Drush commands via a shell scripts.

I'm trying to decide if it makes sense for me to invest the time in learning how to use Phing.  I'm looking for some clarity as to what benefit I will gain by incorporating Phing vs. Drush commands via Shell script.

So my question is for those who use Phing with Drush and Jenkins: how is it that Drush/Drush-Make and Phing differ?  Why did you decide to start using Phing in your process?

Thanks


texts: Profile Address fields not filling with Loqate

texts:
I'm working on a D8 Commerce site that uses the Profile module, and in the profiles, we're using an Address field. We want to do address verification, so we are using the Loqate module with their service.

Per what I can find in the docs, I'm using hook_form_alter() to add the search field:

if ($form_id === 'profile_shipping_information_address-book-edit_form' ||
          $form_id === 'profile_shipping_information_address-book-add_form' ||
          $form_id === 'profile_billing_information_address-book-edit_form' ||
          $form_id === 'profile_billing_information_address-book-add_form') {
    $form['shipping_address'] = [
      '#type' => 'pca_address_advanced',
      '#title' => t('PCA Shipping Address'),
      '#show_address_fields' => FALSE,
      '#allow_manual_input' => FALSE,
      '#pca_fields' => [],
      '#pca_options' => [],
    ];
  }

This works great, in that I can search for and find an address. However, when I select my address, it doesn't fill in my form fields. From what I've seen seen, all my field names are being picked up by the module. Here is my field mapping settings page:

The pca_address submodule is supposed to handle this, so I know the functionality is there. Is there something else I'm missing?


texts:
I changed my Five Star style in a content type to Minimal, but when I add that field in a view it shows in Default style (stars) and as you may guess I want it to display in Minimal style here too.
How can I change its style now? (I'm using Drupal 7.1)
Thanks.


texts: How to access individual theme settings from code?

texts:
I was building a block for which I have to provide bubblable metadata. The data in this block is depending on individual theme configurations as well as the global theme settings.

So I tried the following:

$config = \Drupal::config('system.theme.global');
$bubbleable_metadata->addCacheableDependency($config);

$config2 = \Drupal::config('bartik.settings');
$bubbleable_metadata->addCacheableDependency($config2);

This however obviously does not work if the theme is not set to bartik. I have been attempting to find the theme configuration in \Drupal::theme()->getActiveTheme(), but that does not provide this data.

I suppose I could try $config = \Drupal::theme()->getActiveTheme()->getName() . '.settings';, but I'd like to learn if there are better ways.

How to get the configuration (or config name) of the current active theme?


texts: Entity Reference Autocomplete on 2 fields entity

texts:
Now I have a content type offer with some fields AND an entity reference of the content type product. The entity reference is an autocomplete widget.

When you create an offer, you type in the title of the product. But I also have some other fields on my product like cnk for example. So now I would like to have the possibility that you can also type in the cnk. So you get a list of possibilities that match the title AND the cnk field.

How could I do this?


texts: Site performance , cache not working properly

texts:
I am using the Performance Logging Module. Above screenshot, one strange thing I noticed that Insert Cache_bootstrap on every page. When you go to any page (both admin theme and frontend theme) Insert cache and then delete cache is running. It  means that cache is set and destroyed in each page and actually no cache is occurring. How can I further elaborate it? To diagnose that issue because currently I am working on performance of the site.

I am also using New Relic for performance check. It also shows that database load is high.

and my.cnf information.


texts: Adding Node-Fields to query with db_select();

texts:
I am building a query using db_select(); Now I need to sort my result by a field that a added using fields. Is there some nicer way than to join field_data_field_fieldname, and revision?

I was hoping for something like $query->addFieldData("field_foo", "myfoo"); so i can simply $query->orderBy('myfoo', 'asc');

I am also wondering why there is no example in the API that joins node-fields.


texts:
I've added this code to show user picture under own post and it works perfectly but when i logged out , i cant see user picture !!??

<div class="user-pic">

            <?php
            $user = user_load($user->uid);
            if($user->picture){
                print theme_image_style(
                    array(
                        'style_name' => 'user-pic',
                        'path' => $user->picture->uri,
                        'attributes' => array(
                            'class' => 'avatar'
                        )
                    )
                );
            }
            ?>
        </div>

Any advice ?


texts: Watchdog errors with location = http://default/index.php

texts:
Looking through recent log messages, I've got a number of errors with no referrer listed, and showing location as being http://default/index.php (instead of http://mysite.com/some/page). They all seem to be triggered by "Anonymous" from localhost (127.0.0.1). Example screenshots are below.

Anyone know what kind of sense I should make of these entries?

Example screenshots:

Here's one where location is not http://default, but http://localhost... again, why?


texts: What to do about an 'illegal Choice' error in views?

texts:
I have a view with an exposed filter and it isnt working correctly.  I am trying to change the options on the exposed filter but all that happens is I get is 'An illegal choice has been detected. Please contact the site administrator. '  I cant find anything logging anywhere.  This error is incredibly vague and tells me nothing about which choice is illegal or what legal options may be.

Is there somewhere this may be logged that I am not looking?


texts:
I am trying to create a node from a different server via REST API, utilizing the Drupal 8 REST API and the Poster plugin for the browser.
I posted the request as shown below, and I got the following output.

{
    "message": ""
}

I already enabled the service end_point to create, retrieve, update, and delete the content in the REST API configuration.

What is happening? Is it the right way of doing it?


texts: How to change the value of a field in its preprocess method?

texts:
I am trying to figure out Drupal 8's $variables array ...
So I have a MYTHEME.theme file, complete with a working MYTHEME_preprocess_field() function. (I know it works because I use it for other fields that need customization.)
Right now I'm focusing on the title of an article displayed on the front page of my site. I can access it with the following code.
if ($variables['field_name'] == 'title') {
    $title = $variables['element'][0]['#context']['value'];
    // ...
}

What I want to do is replacing all instances of ® (the registration mark) with <sup>®</sup>. However, setting this value in the array to something else does not change it on the site.
Is there something I'm missing? A few sources I found said to alter (or add) the #markup element in the array, but there's a death of information about this online.
How do I change the value of a field? This seems like it should be something basic and easy to do.


texts: Search API: getAutocompleteSuggestions in D8?

texts:
How can I use the function getAutocompleteSuggestions() in Drupal 8?
In Drupal 7 you could do something like this:

$query->getIndex()->server()->getAutocompleteSuggestions($query, $this->getSearch(), $incomplete_key, $user_input);

Thank you for your help!


texts: View of taxonomy terms that are used giving duplicates, even with distinct

texts:
I am trying to make a view of taxonomy terms that are used in content.

I created a test content type with a taxonomy term field, and used devel to generate content.

I've created a view of taxonomy terms, and added a relationship to the content with that taxonomy field:

Edit As stated above, I created a taxonomy view. I don't think these symptoms are caused by nodes being the base table

And, naturally, it duplicated a row for the taxonomy term for each content that contains that term:

I just want a list of the taxonomy terms used, with no duplicates, which would be this:

rudusteueph
dacigiwucl

So I made the relationship required:

which got rid of spathew. Then I removed the title field from the view. However I was still getting duplicates of each content by each term:

Since I don't want any duplicates, I checked Distinct:

However, I am still getting duplicates. How can I get a true DISTINCT result set?


texts: How do I get the plain text value for the {{ label }} field in a twig node template?

texts:
Very simply put, I want to print the plain text from the title field of my node without any additional html. Currently I have this in my node--custom-template.html.twig file

      {{ label }}

but it outputs it like this

          My Title

I'd like it like this

My Title

I've tried using some of the twig filters like |striptags and |raw, but then nothing displays. I'm wondering if there is a template I could edit for this field, or any other way to just get the plain text string of the node title.


texts: Webform emails flagged as spam, emails sent from outside Drupal not flagged

texts:
Our Drupal installation uses Webform and Mime Mail. Emails sent from our webforms are getting flagged as spam by Gmail and other providers. We also have some email scripts running on our server outside Drupal whose emails are not getting flagged as spam, so I know our IP address has not been blacklisted. I've spent some time tinkering with the headers on the webform emails, to no avail. Here are the headers from one of our Webform emails:

Delivered-To: jesseloesberg@gmail.com
Received: by 10.114.109.35 with SMTP id hp3csp217457ldb;
    Fri, 5 Dec 2014 10:42:48 -0800 (PST)
X-Received: by 10.66.248.36 with SMTP id yj4mr30814419pac.51.1417804967335;
    Fri, 05 Dec 2014 10:42:47 -0800 (PST)
Return-Path: <mslavin@hnu.edu>
Received: from 69-64-86-100.phx.dedicated.codero.com ([69.64.86.100])
    by mx.google.com with ESMTPS id da5si48803543pdb.204.2014.12.05.10.42.46
    for <jesseloesberg@gmail.com>
    (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
    Fri, 05 Dec 2014 10:42:47 -0800 (PST)
Received-SPF: pass (google.com: domain of mslavin@hnu.edu designates 69.64.86.100 as permitted sender) client-ip=69.64.86.100;
Authentication-Results: mx.google.com;
   spf=pass (google.com: domain of mslavin@hnu.edu designates 69.64.86.100 as permitted sender) smtp.mail=mslavin@hnu.edu
Received: from nobody by 69-64-86-100.phx.dedicated.codero.com with local (Exim 4.84)
(envelope-from <mslavin@hnu.edu>)
id 1Xwxq1-0002dQ-TD
for jesseloesberg@gmail.com; Fri, 05 Dec 2014 11:42:45 -0700
To: jesseloesberg@gmail.com
Subject: Your recent interest in HNU
X-PHP-Script: www.hnu.edu/index.php for 107.1.132.130
MIME-Version:1.0
Content-Type:multipart/mixed;
boundary="2f4e6192994ec7ee1ec9251859f0041c248e044c1"
Content-Transfer-Encoding:8Bit
X-Mailer:Drupal Webform (PHP/5.4.30)
From:"Matt Slavin" <mslavin@hnu.edu>
Reply-To:mslavin@hnu.edu
Message-Id: <E1Xwxq1-0002dQ-TD@69-64-86-100.phx.dedicated.codero.com>
Date: Fri, 05 Dec 2014 11:42:45 -0700
X-AntiAbuse: This header was added to track abuse, please include it with any abuse report
X-AntiAbuse: Primary Hostname - 69-64-86-100.phx.dedicated.codero.com
X-AntiAbuse: Original Domain - gmail.com
X-AntiAbuse: Originator/Caller UID/GID - [99 99] / [47 12]
X-AntiAbuse: Sender Address Domain - hnu.edu
X-Get-Message-Sender-Via: 69-64-86-100.phx.dedicated.codero.com: uid via acl_c_vhost_owner from authenticated_id: nobody from /only user confirmed/virtual account not confirmed

Any thoughts about why these emails are getting flagged where our non-Webform emails are not are greatly appreciated.


texts: Error when trying to upload a Configuration Synchronization file

texts:
I want to create a local copy of a production website. I read that I could use Configuration Synchronization to copy some of the settings of the production website over to my local website. When I try to upload the exported .tar file from the production website to my local website, I get this error:

Could not extract the contents of the tar file. The error message is Invalid checksum for file "Y3drj:+uT}vG|59ooc&{C:BS1@/f/" : 65255 calculated, 0 expected

I'm using lando to host the website locally. I also had to delete some of the characters in the error message above because stack exchange wouldn't let me post them.


texts: How to hide a view if it has more than 1 row and also show some block if this is true?

texts:
I have found a solution in "Hide a view if less than N results" for hiding the view by using the template.php file.

However I need to show a certain block also, the block is already in the correct region it would just need 'switching on' for this page.

Would it be possible to provide a callback inside the following code from the link posted above

function MY_THEME_NAME_preprocess_views_view(&$vars) {
  if ($vars['display_id'] == 'MY_DISPLAY_ID' && count($vars['view']->result) < 1) {
    $vars['view']->result = NULL;
  }
}

To a function which turned the block on

Note: I am just starting module development.

edit: I'm now thinking that this would need to be done inside a custom module as it might be too late to turn the block on from the template.php file. If someone could clarify this.


texts: As content author creates a page, she wants to have something like . Is it possible? the goal is to avoid hard-coded drupal installation path; that is she doesn't want to have  on test site and  on production site.


texts:
I cannot find the list in the api documentation.

https://api.drupal.org/api/drupal/core%21modules%21views%21views.api.php/group/views_hooks/8.5.x

Nor am I able to enter such functions in a theme when loading a page with a view.


texts: How to generate absolute URL for breadcrumbs?

texts:
I am use Easy Breadcrumb module for a D8 site. I have everything I need with this module as it alters the existing Breadcrumb block, but it outputs relative URLs.

How can I change the relative URLs to absolute?

Current issue (Breadcrumb Output):

    level One

    level two

    level three

Current Level

Expected output:

    level One

    level two

    level three

Current Level


texts:
I created a content type called: Spreed Sheets. Then in /admin/people/permissions I make sure I checked these 3 permissions for authenticated users :

  Spreed Sheets: Create new content

  Spreed Sheets: Edit own content

  Spreed Sheets: Delete own content

then I loged in with an authenticated user (not admin) and I only have access to node/add/spreedsheets but when I'm login with admin and want to add another content type such as article from admin/content/add content it always redirect me to node/add/spreedsheets !!what should i do to give back the full permission to admin?


texts: I've seen this question posted elsewhere here but I haven't seen an answer for it. I am new to Drupal and I'm interested in installing some modules via the Drupal interface, but I don't see the "Install New Module" link on the modules page. (Yes, update manager is already enabled, and going to admin/modules/install doesn't get me anywhere).


texts: How to determine if the current page is a search results page?

texts: How can I determine from within a module or theme if the current page is an Apache solr search results page?


texts: I have create a custom block using Bean. It have a field collection and that field collection have 8 values. I have create a bean.tpl.php to override block. Now i need to know how can i get that field collection values using loop inside bean.tpl.php file.


texts:
I've a view filled with events. Some events carry a date, some don't.
How can I leave out those without a date? There should be somewhere a empty($date) ? hide($view) : break;. But I don't know how to do this with a view. Any suggestions?


texts: Is there a maximum amount of data that a Drupal database can safely store?

texts: Is there a maximum amount of data that a Drupal, let's say MySQL, database can safely store? If it gets too big will problems start to occur?


texts: Default values to field collection module

texts:
I have a field_collection, with:

  taxonomy select - number(price) - and Rating

To add a value, you have to click the "add more" button.

Is there any way to do it simpler, or at least to set default values?


texts: How to find the path of the feed for content type in drupal 7?

texts: I wanted to add the path to the feed view display, but I'm not able to know what the path is?


texts: How can I attach an image from an existing image field to another multi-value image field?

texts:
I have the nodes that have the source image field field_old_image_field and the destination image field, field_new_image_field. field_old_image_fieldhas only one image. field_new_image_fieldcan have multiple images and probably does. I need to copy the image from field_old_image_field to field_new_image_field without disturbing the images that are already in field_new_image_field.
Here's my code so far:
foreach ($nodes as $node) {
    if ($node->hasField('field_old_image_field') && !empty($node->field_old_image_field->target_id)) {
      $image = $node->get('field_old_image_field');
      $image_uri = $image->entity->getFileUri();
      $image_alt = $image[0]->get('alt')->getString();
      $image_title = $image[0]->get('title')->getString();

      $node->get('field_new_image_field')->appendItem([
        'target_id' => $image,
        'alt' => $image_alt,
        'title' => $image_title,
      ]);
    }

    $node->save();
  }

But when I run this code in an update hook, I get
In EntityReference.php line 106:

Value is not a valid entity.

I was getting it to work earlier, but I wasn't getting the alt text or the title text copied over. What's wrong with this code and is there an easier way to do this?


texts: How to get update status of multiple Drupal sites

texts:
I have several servers each with numerous Drupal sites on.
Not all of them are developed by me.

How would you keep on top of the sites to make sure they are all up to date security wise.
In an ideal world I would like them to report to a central location. From that one place I can be alerted.

Worse case I will write my own module to call a Web Service and send the status across. How ever if this has all ready been done will save some time.


texts:
I have a node field named event_date which contains multiple values of dates.

The table for the field looks like this:

node__field_event_date
+----------------+------------+
| entity_id(nid) | event_date |
+----------------+------------+
|              1 | 2019-1-1   |
|              1 | 2019-1-2   |
|              2 | 2019-1-3   |
|              2 | 2019-1-4   |
+----------------+------------+

I would like to join only earliest event_date for each node to the node base table(node_field_data).

node_field_data(short version)
+-----+--------+
| nid | title  |
+-----+--------+
|   1 | event1 |
|   2 | event2 |
+-----+--------+

The ideal result is:

+-----+--------+----------------+-------------------+
| nid | title  | entity_id(nid) | EarliestEventDate |
+-----+--------+----------------+-------------------+
|   1 | event1 |              1 | 2019-1-1          |
|   2 | event2 |              2 | 2019-1-3          |
+-----+--------+----------------+-------------------+

In raw sql, it can be written like this:

SELECT * FROM `node_field_data`
INNER JOIN (
  SELECT entity_id, MIN(field_event_date) AS EarliestEventDate
  FROM node__field_event_date
  GROUP BY entity_id
) AS event_date
ON node_field_data.nid = event_date.entity_id

But the problem is, the join should be done as a part of query for a View.

I tried the code below, but the Views didn't parse the subquery at all.

// in MY_MODULE.module

/**
 * Implements hook_views_query_alter().
 */
function MY_MODULE_views_query_alter(ViewExecutable $view, QueryPluginBase $query) {
  if ($view->id() === 'events') {

    $subquery = "(SELECT entity_id, MIN(field_event_date_value) AS EarliestEventDate FROM node__field_event_date GROUP BY entity_id) AS node__field_event_date";

    $definition = [
      'table' => $subquery,
      'field' => 'entity_id',
      'left_table' => 'node_field_data',
      'left_field' => 'nid',
    ];

    $join = Drupal::service('plugin.manager.views.join')->createInstance('standard', $definition);
    $query->addRelationship('event_date', $join, 'node_field_data');
  }
}

What appeared on SQL preview in the view editing page:

LEFT JOIN {SELECTentity_idMINfield_event_date_valueASEarliestEventDateFROMnode__field_event_dateGROUPBYentity_idASnode__field_event_date} event_date ON node_field_data.nid = event_date.entity_id

Maybe I should try Views Plugin? But I don't have much experience making it and have no idea plugins can accept subquery like this.

If anyone have thoughts or ideas please give me advice...


texts:
I've been doing some w3 validation but I find that my menu's are missing a <ul> for the <li>'s. I have read Where is links__system_main_menu defined? but this doesn't really answer my question. I understand that

  links__system_main_menu is a theme hook pattern of the form [base
  hook]__[context]. When links are themed with
  theme('links__system_main_menu', $vars), theme() will search for and
  use theme_links__system_main_menu() if it has been defined. If not, it
  will use theme_links().

The theme i'm using doesn't do much as far as modify the menu system at first glance. In the theme.php file, it contains:

$variables['main_menu_themed'] = theme(
    'links__system_main_menu',
    array(
      'links' => $variables['main_menu'],
      'attributes' => array(
        'id' => '',
        'class' => array('links', 'clearfix'),
      ),
      'heading' => array(
        'text' => t('Main menu'),
        'level' => 'h2',
        'class' => array('element-invisible'),
      ),
    )
  );

How can I modify the actual output of the menu?


texts: Is it possible to change the Taxonomy Parent Term's select list to be a Hierarchical select list?

texts:
The Taxonomy relations > Parent terms select list is lengthy to look through so ideally we'd like a Hierarchical select list. We already use the Client-side hierarchical select module for other fields, but it doesn't appear to be designed for this particular field. Is there a way for me to programmatically apply the module to this field by altering the form in hook_form_alter()?

We've considered using the Chosen module but an autocomplete isn't exactly the functionality we're hoping for. I also understand there's the Simple hierarchical select module, but since we already use CSHS, I wasn't sure if it was advisable to have both CSHS and SHS. For the time being we've changed ['#multiple'] = false; to turn it into a basic drop-down.


texts: Some menu item visible only for user browsing from outside India

texts:
How to make some menu item of main-menu visible only for user browsing from outside India.
Pls suggest any solution


texts: How to handle exceptions in a batch process

texts:
I have some special configured content entities in my system which are protected in a pre-delete hook against entity deletion.
There is also a batch process (VBO - entity delete) where they can be selected before hand.

I want to handle gracefully the exception in a batch process which wasn't written by me (and cannot be touched). I tried to subscribe to the exception event and look for xmlHttpRequest which was all fine, but then I dunno what response to set back to stop the process, or log the exception within the batch process with the proper message. What I always get back is this, where the error message is what I put into the AjaxResponse body:

Any help appreciated find a more sophisticated solution to redirect from the batch processing in case of an exception.


texts: Drupal 7, Aggregator, RSS no longer imported: The feed from $ seems to be broken, due to an error "Invalid document end" on line #

texts:
I run a Drupal 7 website and have a separate WordPress blog. The blog generates a feed, which I display (RSS2 version) in a Block on the Drupal website via the Aggregator core module. This worked fine until somewhere in December.

The last update post/feed shown on the Drupal website is from 24 Nov. '17. The newer 2 posts have not made it onto my Drupal website. However, when I check the feed itself, the posts are present in the feed.

Drupal website: https://www.lovedominique.co.za/

Feed of blog: https://lovedominique.co.za/blog/feed/

The error message that Drupal shows is:

  The feed from New On Our Blog seems to be broken, due to an error
  "Invalid document end" on line 128.

I checked the feed on http://www.feedvalidator.org/ (link). There is no mention of line 128 on feedvalidator. But, another error shows up for line 187:

  line 187, column 0: url must be a full URL:
  https://lovedominique.co.za/blog/wp-content/uploads/2017/10/adding_texture.mp4

I don't understand why I am getting these error messages. The lines look okay to me.

Installed updates
I deleted my browser's cache (Firefox ESR).
I deleted the Drupal cache (on the server).
I added a new test post to the blog, and confirmed that it shows on the feed (https://lovedominique.co.za/blog/feed/). Yet, it does not get imported by Aggregator.


texts: Drupal 7 views contextual filter (taxonomy: summary display), displaying a readable term-name instead of term-id

texts:
Within my view, I'm using a contextual filter—with a default "summary output"—to filter my results by taxonomy term.

The problem is that the summary-result is grouped by a listing of taxonomy term-id's (including a node count) and not human readable term-id names.

1 (21)
2 (16)
etc.

Is it possible to change (or hook) the view output of the summary, by not listing its term-id's, but the term-id-name?

Term name A (21)
Term name B (16)

(It doesn't bother for me if the actual request URL stays the same.)

My goal is to create a more readable output-format of my taxonomy-term summary, which an end user can understand.


texts: I am in the process of making a social networking web site with Drupal7. Most of the tasks are done. However, i am stuck at this issue big time. I have created custom content type, Challenge. Using the flag module, i have placed a flag, Accept Challenge, on the nodes of this content type. Users click on this flag and accept the challenge. Now to complete the challenge users, have to post a blog about their challenge. So is there any way that when the user goes to node/add/blog and begins blogging, in the title field he or she has a drop down to pick from the nodes he has flagged. The name of the title should be same as that of node which was flagged. Please advice.  I hope i am clear. If not, please tell me and i would try my best to be as clear as i can


texts:
I have the following code in my custom.module (using it in hook_init()):

if ($js) {
  // Required includes for ctools to work:
  ctools_include('modal');
  ctools_include('ajax');
}

if (user_is_logged_in()) {
  $title = 'hello';
  $output = 'more hellos';
  ctools_modal_render($title, $output);
} else {
  return NULL;
}

Problem is if even i'm not logged it shows to me a modal windows with infinite loading text. How to unset ctools_modal_render() if i am not logged in?


texts:
I'm aware of the Role Delay module however it is not working for me. I'm running D7. I read somewhere that it is possible to do the same thing with Rules.

The 3 stages I want users to go through are...

1) Non-authenticated user
2) Authenticated user
3) Trusted authenticated user

I've got the movement from 1) to 2) working fine as it's taken care of by the Logintoboggan module (upon account activation). Moving 2) to 3) is proving trickier as I want it to be time based, after the 1) to 2) event.

All I want users to move from 2) to 3) in 24 hours after they become an authenticated user.


texts:
For some reason I'm stuck on this!

Is there a setting in webform so that I can simply click on reply when I receive and email from contact form?

Been out of the loop for a while for health reasons!


texts: Why is the 'time ago' not displayed in my view?

texts:
I'm not sure whether this is a bug or not, so I'm just going to ask this. I created a view (and block) with a 'Comment: Post date' field with 'Time ago (with "ago" appended)' as Date format. I didn't fill in a custom date format.

Everything is previewed perfectly, but when I go to my dashboard, I only see the "ago": the actual numbers (hours, minutes, seconds...) aren't displayed.

I cleared caches, but nothing happened. I'm still using the default Seven 7.23 administration theme for my dashboard and I didn't set a custom template file or anything else. I just created the view.

How can I solve this?

Edit: I exported my view, so you can read the code here.


texts: Remove Caption and next/previous arrows from Colorbox for Node

texts:
To display Node in Modal, I am using colorbox node module

I changed the settings in Colorbox module to not display any information like Current, Next, Previous, etc. like:

however I can still see that small arrow and node count as shown in the picture below:

How do I remove these small arrows and count overall and only have that Cross(X) to close the Modal.

Edit: I cleared the cache and this 4 of 41 is gone... but those arrows are still there.


texts: Import CSV, converting repetitive fields to taxonomy terms

texts:
Let's say I have a CSV file like this:

NAME, TYPE, COLOR
apple, fruit, green
banana, fruit, yellow
kiwi, fruit, brown
carrot, vegetable, orange
potato, vegetable, brown

You get the idea. Is it possible to import this CSV file such that specified fields (in this case TYPE and COLOR) are taxonomies, and new taxonomy terms are created automatically?

I really want to do this in Drupal 8, but perhaps a method would be to do it in Drupal 7 and then migrate the data.


texts:
I've been developing a Drupal site for over a year on my MacBook. The production server that the Drupal site will run on is Windows Server 2008 R2. As I try and load the SQL file from my MacBook, I'm getting this error from my MySQL client: "This file contains mixed linebreaks. They have been converted to Windows linebreaks." Then the import crashes. Can anyone share some tips with me on how to sucessfully migrate the Drupal database to Windows w/o carrying over assorted character/encoding problems?

Also-because the Drupal URL of the site on Windows is something other than "localhost", I end up having to edit the exported SQL file(s) either in TextMate (on Mac) or in Notepad++ (on Windows) to change the URLs. Could this also be contributing to the problem? I have also noticed in Sequel Pro that in the "field_data_body" table that there are hard returns everywhere. Is this normal?

Sorry if this is a dumb question, but I'm at my wits end and on a tight deadline. Thanks so much,

Jason

--Added on 2/9/14--

Here's some additional details related to my original question.

First, I realized that the Mac version of my database contains Windows line breaks (\r\n) and not OSX line breaks (\n). If my production MySQL server runs on Windows, should I even bother to try and convert the incorrect line breaks on my mac development site?
Importing using Backup & Migrate doesn't usually work from my Mac to my Windows server because the Windows server usually crashes. So I have to start the site off on Windows by importing the schema and data files separately. Schema imports fine, but the data file import encounters SQL errors from these issues: apostrophies in block of text (i.e., Drupal's, site's); brackets (i.e., 'Your membership request was approved for '[og_membership:group:label]' in an insert statement), anyplace where % or @ occurs.

I've tried putting a backslash before the offending characters in some tables, but don't want to do this for the whole data file. Is there something I'm doing wrong when exporting SQL files on my Mac that is causing these problems?

One thing I just remembered is that I had to uninstall and then reinstall MAMP on my Mac two weeks ago. Before this, I never encountered these type of import errors, on my Mac at least. I checked my MySQL config. file and the only difference is that I declared InnoDB as the default storage engine. I did not have this in my previous MAMP installation.

Thanks for any assistance.

Jason


texts: Programmatically update alt tag on image field

texts:
I have a Drupal 8 site with a content type that has an image field. For existing nodes of this type, most have image files, but none have alt tags.

I am writing an update hook where I want to set the alt tag value for existing nodes. However, I have not been able to figure out how, nor find documentation.

This is what I have:

$nids = \Drupal::entityQuery('node')->condition('type','sfa_social_post')->execute();
$nodes = \Drupal\node\Entity\Node::loadMultiple($nids);

foreach ( $nodes as $node ) {
  $node->field_sfa_image_file->alt = 'Image for ' . $node->getTitle();
}

Where field_sfa_image_file is the name of the image field.

When I re-loop through the nodes, I get back the value that I set.

$nids = \Drupal::entityQuery('node')->condition('type','sfa_social_post')->execute();
$nodes = \Drupal\node\Entity\Node::loadMultiple($nids);

foreach ( $nodes as $node ) {
  drush_print('Title: ' . $node->getTitle());
  drush_print('Alt: ' . $node->field_sfa_image_file->alt);
}

Which gives me

Title: Instagram Post ID: 1917569620391415985_3017827348
Alt: Image for Instagram Post ID: 1917569620391415985_3017827348
Title: Instagram Post ID: 1917562614863492125_3017827348
Alt: Image for Instagram Post ID: 1917562614863492125_3017827348

So all seems good. However, when I navigate to nodes, I don't see my alt text:

How do I set the alt tag for an existing image field?


texts: Views exposed filter auto submit loses focus

texts:
I have setup a view with ajax enabled. I have also added an exposed filter with autosubmit on so that as the user types in the text field the view will automatically update. The problem is that when the form autosubmits, the text box loses focus.

I have read that I need to separate the exposed form into a separate block, however this option is not available as my view is a block itself.

Any help would be appreciated, as it is a real pain having to keep clicking in the text box to keep typing.


texts: How to delay the execution of a rule for 5 minutes?

texts:
I'm using the module "Facebook Autopost" to post Drupal content on Facebook. When a new node is created, a link to this node is posted on a Facebook page. Facebook's scraper picks up the link and tries to scrape this.

This is configured in a rule. Currently, it looks like this:
http://imgur.com/rtIiYLL

When a new node is created, the rule is executed. The link gets posted on the Facebook page, but the scraper seems to get a 404. It appears the rule is executed too fast, BEFORE the actual node is created.

Is there a way to delay the execution of the actions so the node is actually created already?


texts: Is it possible to change an option or overwrite the password validation so that a user can add characters like é to their password?


texts: Which is the DRY-est way of organizing taxonomy terms under submenus?

texts:
Given the Active Sales view with 3 Displays each having their own content type (of the same name) and url path:

Active sales ( /active-sales )
Announcements ( /announcements )
Portfolio ( /portfolio )

each of them having a vocabulary (with the same name: eg. Active sales -> Active sales (vocabulary)) and each vocabulary having its own terms per se:

Active sales

movable property
non-movable property

Portfolio

finished contracts
organisational procedures

etc..

I want to organize the taxonomy terms as Submenus with their own url-path having the dictionary url-path as parent

Active sales (parent) url-path: /active-sales

movable property (child 1 submenu): /movable-property
non-movable property (child 2 submenu): /nonmovable-property

Which is the DRY-est way of achieving this?

My first thought was to create another View called Submenus and make an url-path for each dictionary term and order them in the Main Menu.


texts:
I have created a basic page - "About Us" and provided it a menu link under Main menu.
Now I have created 3 more basic page as sub-menu of About us.

So, the hierarchy is like:

> Main Menu
>
> --About Us
> ----sub-menu1
> ----sub-menu2
> ----sub-menu3

Now, what I want to achieve is, when "About us" menu is clicked, all its sub-menus should rendered at left, in sidebar left block and its related content on right.

Also when I click sub-menu1, page should not get refresh. i.e; the url should become something like: about-us/sub-menu1.

I know, this url is possible if I use About-Us as content type. But I'm using it as basic page.

Any suitable approach to achieve this?


texts: Group of CCK fields assigned to the same NID without an additional Node type and Node referrence

texts:
I want to implement a 1 to N relation of a group of CCK fields into the same Node type

Picture this: I have some projects and some expenses per year
I have to define each year and it´s total expenses and provide a short description and some images for each year...

I wanto to make it into the same page... not define two types of content to implement a node referrence where I define the years and it´s corespondent description and images

something like this:

I don´t know how can I implement this with Drupal...
There is a matrix/array type of CCK field but it doesn´t support the installed CCK
it has it´s own stadard types..integer, text etc... so it won´t do ..

Is there any way to obtain this?

the main functionality (ignore the layout ..it can be horizontaly as well)

when I click Add More, ... to add All those fields grouped so I can edit them....
It´s like embeding the other content type into the related NID upon creation of the NID...

Using Drupal 6 and the last CCK available
upgrades are not a problem, I can use the latest versions as long they are for D6

re-edit

I have to explain myself better because what I´ve described I see is not very understandable...

Picture the following requirements (based on a relational database concept)
I have a content type named Project Expenses (title, description, project status)

Now I want to describe for each year how much I´ve spent for the project and add a gallery of images with the projects achievements for that particular year.

Now, the common thing would be to add another content type with the following CCK fields (year, amount, image (unlimited multiple values) and a node referrence to the project itself )

The problem I have is at data input.. you have to first create the project...save it
then add another node for each year and selecting the project in the node reference dropdown doing the relation between the node and the other (1 to N relationship in therms of a database)

So 2 forms instead of one... 2 saves...
This is not cool for the user experience, because normal users don´t know the steps or it results too complicated..(this is a simple example but it can get really complicated with having to fill in a lot of nodes if we have more relations)

Ok, so the solution: embed into one form everything..(multiple pages input would be also a solution) but my ideal would be something like in that image that i gave you

define on the same page the other node as well automaticaly making the relation when saving the main node (the project)

I don´t have any ideea how it´s possible (I could find only one module that does that but the values arren´t in fact CCK fields so can´t use them propperly it´s called matrix field )

Show how is the best way to do this?


texts: I am trying to create a view of nodes that have a taxonomy reference field. I can get the taxonomy term but do not see the taxonomy fields that I've created exposed to views. Google searches do not reveal anyone else having the same issue. Am I missing something right under my nose?


texts:
I'm trying to load a service into my Drupal module, but even after checking twice whether I did something wrong, I can't seem to find any error in my code as I did everything as the documentation said and Drupal still gives me a non-existent service error.

Here's the my services.yml file:

services:
  rb_weather.wunderground:
    class: Drupal\rb_weather\WundergroundWeather

Here's the config form code (the part loading the service):

class RBWeatherSettingsForm extends ConfigFormBase
{
/**
 * @var WeatherInterface
 */
private $wunderground;

public function __construct(ConfigFactoryInterface $config_factory,    WeatherInterface $wunderground)
{
    parent::__construct($config_factory);

    $this->wunderground = $wunderground;
}

public static function create(ContainerInterface $container)
{
    return new static(
        $container->get('config.factory'),
        $container->get('rb_weather.wunderground')
    );
}

I have included the classes using the "use" command as PhpStorm doesn't complain about that, however, Drupal does not want to recognize it.

My service classes as well as the services.yml file are placed under rb_weather/services folder.

Thanks a lot.


texts: How can I migrate a site into an organic group

texts:
I have several sites that are being migrated from Drupal 6 to Drupal 7.

However, most of these sites are very small and all have a lot in common (similar content types, fields, views, etc...). So, instead of migrating each site individually, I am migrating the content for all sites into a single site, changing the instances of each D6 site into an Organic Group on the D7 site.

Since the content types are the same (or similar), I'm re-using the same node migration classes (extensions of DrupalNode6Migration in the node.inc file).

I'm passing along the group id in the arguments array to associate the nodes with the D7 Organic Group. However, I'm not sure how to go about doing this.

The code (I believe) for programmatically associating a node with an organic group is this:

og_group('sub_site', $arguments['group_id'], array(
  "entity_type" => 'node',
  "entity" => null, // need current entity
));

However, I don't believe I have a reference to the created entity within the migration class itself (at least not in the construct() or prepareRow() functions).

You know what? I think I just solved my own problem. I'm going to try using the complete() function, which has access to the finished node, like this:

class myClass extends DrupalNode6Migration{

    public $group_id = '';

    public function __construct($arguments) {
        parent::__construct($arguments);

        // set group id member variable to use in complete() function
        $this->group_id = $arguments['group_id'];

        // mappings and stuff

    }

    public function complete($node, stdClass $row) {
        if (parent::complete($node, $row) === FALSE) {
            return FALSE;
        }

        og_group('sub_site', $this->group_id, array(
            "entity_type" => 'node',
            "entity" => $node,
        ));
    }
}

Leaving this here in case it helps somebody else.

I can't test this yet, unfortunately. When I do, I'll try to remember this post to let people know how it worked out.


texts: How to exclude a field when a search is done?

texts:
I just enable the Search Form (provide by the search module) block to allow the visitor to make searches.

When a search is done the entered word is searched in all field of the nodes.

Can I exclude a field?

Let's say the content type has the fields: title, body and provider.

Then when a search is done I need to exclude the field provider from the search.

I have the custom_search module enabled but I see no way to exclude fields.


texts: is it possible to create a menu item that links to the node that references the current user? I can create a more or less suitable solution with views: a page that contains the referenced node but it'd be more user friendly if the menu link contained the URL of this node.


texts: I'm new to Drupal and I am doing some module development for a Drupal 7 install.  I've done development outside of Drupal and normally its best to always sanitize user input.  I've seen different opinions of the matter but from what I have picked up is dont use form_state['input'] but what about form_state['storage'] or form_state['value'].  I'm seeing some people say the API does the sanitizing and others say always sanitize.  Can anyone explain to be best practice?


texts: Is there any module that can restrict people from accessing certain pages when they are not logged in?


texts: How do I pass data from one form builder to another?

texts:
I have a page callback that does this:

// ...
$page['search'] = drupal_get_form('search_form');
// ...
$page['list'] = drupal_get_form('list_form');
// ...
return $page;

The first form builds a search box where the user can enter a term that influences which rows should be presented in the following table. (which is also a form, but that doesn't necessarily matter, right?)

How can I get at the values in $page['search']? Could I construct a form alteration hook? Should I use a different approach altogether in my page callback?

Coming from a Java world, I would be inclined to have an object that has its internal state manipulated by the first call, and the second call using that info for its own output. I'm not sure how Drupal ties this together.