texts: How do I inject a dependency into a @FieldType plugin?

texts:
I am implementing custom fields in Drupal 8 (types, widgets, formatters).

@FieldType plugins are instantiated by their respective plugin manager (\Drupal\Core\Field\FieldTypePluginManager) which does not care about dependency injection.  That is possible for both @FieldFormatter and @FieldWidget plugins if they only implement \Drupal\Core\Plugin\ContainerFactoryPluginInterface.

What would be the alternative way to inject a dependency into a @FieldType plugin?

Notes

@FieldType plugins are actually (implicitely) instantiated by \Drupal\Core\TypedData\TypedDataManager, which does not care about dependency injection
Related drupal.org issue: Allow typed data plugins to receive injected dependencies


texts: CKEditor + IMCE file uploader. What am I missing?

texts:
I've got CKEditor and IMCE modules installed and enabled. I've got an "Insert image" link at the bottom of the "body" text area. However, I can't seem to get the wysiwyg editor to display.

What am I missing?

In admin/config/content/formats
I only have Plain text format.

Should I add Fitered HTML, full HTML and php manually?

Or shoud have they been created automatically with one of the modules?


texts:
Does anyone know how I can theme the entire li output for an expanded menu item?

For instance, the output is

I want to change the output to:

Is there a way to theme this output, like there is a way to theme specifically the expanded menu item output, like there is to theme other li outputs, such as below...?

function theme_menu_tree__main_menu_link($variables) {
  return '
'.$variables['tree'].'
';
}

My current code

function theme_menu_link__main_menu(array $variables) {
  $element = $variables['element'];
  $sub_menu = '';

  if ($element['#below']) {
    foreach ($element['#below'] as $key => $val) {
      if (is_numeric($key)) {
        $element['#below'][$key]['#theme'] = 'menu_link__main_menu_inner'; // 2 lavel

      }
    }
    $element['#below']['#theme_wrappers'][0] = 'menu_tree__main_menu_inner';  // 2 lavel

    $sub_menu = drupal_render($element['#below']);
  }
  $output = l($element['#title'], $element['#href'],     $element['#localized_options']);
  return '
' . $output .
  $sub_menu . "
\n";
}


texts: How to print a variable set in my custom module's inc file in node-contenttype.tpl.php

texts:
I am trying to grab all links under id="ctl00_ctl00_MainPlaceHolder_MainPlaceHolder_TaobaoLink".

Here is the function used in my custom module file:

function _taobao_add_tovar($url){
  $url = str_replace('&amp;','&',$url);
  $tovar_page = _taobao_get_page('http://rutaobao.com/pages/item_detail.aspx?ItemId='.urldecode($url));

  $linkz = _taobao_get_block($tovar_page, '"ctl00_ctl00_MainPlaceHolder_MainPlaceHolder_TaobaoLink" title="Открыть оригинальную страницу этого товара на taobao.com">');
  preg_match_all('%<a [^>]+href="(?P<url>[^"]+)"[^>*]*>(?P<text>[^< ]+)</a>%si', $tovar_page, $linkz);
}

I've set the $linkz variable. How can I print it in node-mycontenttype.tpl.php?


texts:
For my internship I could use some help with the optimization for search engines.

Are there any plugins that will help me increase the SEO performance of the website im trying to optimize? So far I only found a checklist but thats not what im looking for. Wordpress has a Yoast plugin that checks every move I make to optimize it for search engines. Does Drupal have a similar plugin?


texts: Is it possible to make a second "edit account" page that only allows users to edit some profile fields?

texts:
So here is my situation: users on my site have to fill out  a rather large number of fields upon registration.  However, after they register, only four (out of about twenty) of these fields need to be changed regularly.  I would like to create a separate "edit" page to allow users to modify just these four fields to keep things simple.

field_checkbox_a
field_checkbox_b
field_checkbox_c
field_checkbox_d

These fields are all contained in a field group, so ideally the page would show this field group, the four checkboxes inside it, and then have a submit and cancel button, that's it.

I want to do this as a separate page, not in-place editing like the Quick Edit module.

Users still need to be able to access the original edit account page to change their timezone, e-mail address, etc. but I could really use a separate screen to allow them to edit the most common account options.


texts: Form built by Ajax commands not sending values

texts:
My problem has to do with Ajax commands and the form being rebuilt after calling ajax_command_append().

I have a form with two elements an option and a textfield. These are built-in with the form on page load. Then, in an Ajax callback function I add two other fields, i.e. another textfield and a text area.

The form runs and rebuilds perfectly fine, but when I try to read the values typed in or stored-from-beginning, nothing happens except that only the values for the first two fields that were originally built-in with the form are displayed.

I think the problem is either 1) I am not rebuilding the (same?) form properly, or 2) I am not calling the elements/fields properly when reading values.

Any hints will be greatly appreciated

Here is a simplified version of the test code I gathered from various examples:

function module_form($form, &$form_state) {
$form = array();
 $form['changethis'] = array(
 '#type' => 'select',
 '#options' => array(
  'one' => 'one',
  'two' => 'two',
  'three' => 'three',
  ),
   '#ajax' => array(
     'callback' => 'ajax_example_simplest_callback',
     'wrapper' => 'replace_textfield_div',
     'method' => 'replace',
     'effect' => 'fade',
    ),
  );
  $form['replace_textfield'] = array(
    '#type' => 'textfield',
    '#title' => t("The default value will be changed"),
    '#description' => t("Say something about why you chose") . "'" .     (!empty($form_state['values']['changethis']) ? $form_state['values']['changethis'] :     t("Not changed yet")) . "'",
    '#prefix' => '
',
    '#suffix' => '
',
   );
 $form['box'] = array(
   '#type' => 'markup',
   '#prefix' => '
',
   '#suffix' => '
',
   '#markup' => '
Initial markup for box
',
  );

  $form['submit'] = array(
    '#type' => 'submit',
    '#ajax' => array(
      'callback' => 'ajax_example_submit_driven_callback',
      'wrapper' => 'box',
     ),
    '#executes_submit_callback' => TRUE,
    '#value' => t('Submit'),

   );
  return $form;
}

function ajax_example_simplest_callback($form, $form_state) {

   $commands = array();

   $commands[] = ajax_command_append(NULL, '
<input name=replace_textfielddd id=replace_textfielddd value=79898>test data</input>

');

  $commands[] = ajax_command_append(NULL, '
<textarea rows=4 cols=30 name=replace_textarea id=replace_textarea>Changethis value: '. $form_state['values']['changethis'] .'</textarea>');
  $page = array('#type' => 'ajax', '#commands' => $commands);

  ajax_deliver($page);

  //print ajax_render($commands);       // not helping
  //drupal_exit();

 // return $form['replace_textfield'];  // not helping
 }

function ajax_example_submit_driven_callback($form, $form_state) {
   $form_state['rebuild'] = true;  // not helping
   $element = $form['box'];
   $element['#markup'] = "Clicked submit ({$form_state['values']['op']}): " .  $form_state['values']['replace_textfield']. " - ".  $form_state['values']['replace_textfielddd'] ." -.";
   return $element;
}

Thanks

EDIT

I also tried calling this function from the inside of command:
 function display_my_form(){

 $form = drupal_get_form('CPR_Calculator_form');

 $form['replace_textfielddd'] = array(
    '#type' => 'textfield',
    '#title' => t("bye"),
    '#description' => t("ummm"),
    '#prefix' => '
',
    '#suffix' => '
',
  );
  $display = '
';
  $display .= render($form);
  $display .= '
';

  return $display;
}

and then in the callback I replaced the ajax_command_append() with this line:

$commands[] = ajax_command_replace(NULL, display_my_form());


texts:
I am working on a Drupal project and teaching myself the system as I go along. I am trying to find a minimalist theme to use as a base for developing this site. I don't want a framework, because I don't have time to learn that too. I really just want a minimalist theme that looks good out of the box, but that can be easily modified in basic ways.

In my experience so far, most Drupal themes are either overly designed, or completely lacking in any formatting whatsoever. In the WordPress world, there is (for example) something like Thesis, which looks good out of the box but also has lots of potential for modification. Another example would be WooThemes' Canvas. Is there anything similar in the Drupal world?


texts: Views - show only items not in a given nodequeue

texts: Is there a way to filter on the value that is in nodequeue? I want to have a top 5 article list nodequeue, but I want a list of articles after that in terms of most recent is highest, except for those given nodequeue items. Is there a way to do this?


texts: Display only one product-variartion related to a product display

texts:
I am creating a view to display products on my upcoming e-shop. Following is the structure: I am using Search API for this.

When someone navigate form MEN > Half Sleev , the view should display only one color related to a tShirt. I think search_api doesn't support query alter.


texts:
Theme: Basic 8.x-1.x-dev

I am trying to clear theme data after any change is done to twig files.  I see that rebuildThemeData is here: https://goo.gl/EA2YL4

Currently have this within my .theme file.

\Drupal::service('theme_handler')->rebuildThemeData();

\Drupal::service('theme.registry')->reset();

Does anyone have this sort of implementation complete and working for an example?
https://www.drupal.org/node/2608470


texts: Is there a way to set the content to be published on future time instead of future date. I get the message "The 'publish on' date must be in the future" when trying to set publish date to today but late at night.


texts: How can I link the file name to the file?

texts:
I created a content type with a "file" field type. This to upload a pdf file.
Now I want to create a link to open that specific file, in my twig.
If I do this :
{{content.field_menukaart}}
, it opens my file correctly. But I want another link text other than my filename. For example "open here".
This is where I get stuck. How could I do this ?
This is not working :
open here

Thank you for your help,
Basiel


texts: How to add crumb for each search result item?

texts:
I want to add crumb/breadcrumb on each of search result item.

For example, if I search keyword "dog", the search result should return results as follow.

Dog's Life ($title)
Dog is life. Dog is love... ($snippet)
Home > Article > Dog's Life (the crumb)

Dog Dog Who's There ($title)
Who's there dog? Dog dog dog... ($snippet)
Home > Tips Trick > Dog dog Who's There (the crumb)

Usually I construct the crumb using variable $url from search_result.tpl.php via function mytemplate_preprocess_search_result(), implemented in template.php.

I create a new variable, $breadcrumb, based on variable $url and then I call it on search_result.tpl.php. Then I copy search_result.tpl.php into my theme folder.

The problem arises when it is no longer achievable to construct crumb from $url due to circumstances, mostly because of custom breadcrumb that is not related with URL.

Please guide me to achieve that goal, a different approach is welcome. Thanks.


texts: Pull first image from each node to use in view

texts: I want to take the first image from the images each node has in its body, to use it as a thumbnail when displaying nodes in a view. How can I do this?


texts: What is the cause for duplicated XML sitemap links?

texts: I have a site where I have XML Sitemap installed. I am using XML sitemap menu and XML sitemap custom, I see duplicate links in my sitemap.xml file, So what is the cause for that?


texts:
I'm building a module for which I want to create two dynamic menus: one main menu with each menu item being a group name that the user belongs to (the groups come from a different database) and a secondary menu with a fixed set of menu items that manipulate specific properties of the group selected in the main menu (for example show group members).

What would be a good approach to do this? I found this question that shows how to create a menu within a module, but I'm not sure how to tackle the dynamic part of the menu items. Each user can have a different main menu, depending on the groups the user is part of, and the secondary menu items need to pass the group id of the selected main menu item. Next to hook_menu, I suppose I need to do something with wildcards, but I've never worked with those in menus so I'm not sure.

I would like to be able to use the menus as a source for primary and secondary menus in different themes, so I'm flexible with changing the site appearance by selecting another theme. I'm using Drupal  7.


texts: Delete multiple entites without loading them - running out of memory

texts:
I'm deleting multiple nodes like this:

$nids = [21,12,45,67]; // Just an example, this data comes from elsewhere
$nodes = \Drupal::entityTypeManager()->getStorage('node')->loadMultiple($nids);
\Drupal::entityTypeManager()->getStorage('node')->delete($nodes);

Drupal is running out of memory when deleting just 6 nodes.

I'm having this problem in general, not just when deleting, but any time I work with multiple nodes. The PHP memory_limit is 256MB and the server admin is reluctant to increase this. Even if it is increased, it's just postponing the problem - it might fail on 12 or 16 instead of 6.

Is there another way, e.g. to delete based on nid without loading the full node object and all of its fields? The deprecated entity_delete_multiple appears to load the entities before deleting anyway. I suspect it has to because various hooks have to be called and it has to delete revisions and field data.

Or is there some special way I can code it to delete one node at a time and free each object afterwards to keep memory usage low?


texts: Change display order of View block in Content area of page

texts:
I have a dynamic view block that is set to display in "content" region of a Basic page. The Basic page has a field that i want to display at the bottom (i.e. after view block)
Question: I cannot figure out how to change display order, so that page displays View block first, then a field from Basic page. Thanks in advance!


texts: Core Updates after install with composer create-project drupal/drupal

texts:
So I installed Drupal with
composer create-project drupal/drupal <...>

It works fine, but now I'm trying to update core from 8.4.1 to 8.4.4
What's the right way to do that? composer update only updates the modules, not core.
How do I update core? I don't know that much about composer, but if I edit the composer.json and remove

"replace": {
    "drupal/core": "^8.4"
},

and add

"require": {
    "drupal/core": "^8.4",
    ...
 }

it seems to work.
Is this the right way to do this? If so, why is this not in the default composer.json, that comes with the project?


texts: Put blocks, views, etc in git for other developers

texts:
Keep in mind that I'm fairly inexperienced with drupal!

I use a docker based setup for my development environment for docker 7. I'm building a site that involves a front page that will be changed infrequently but I still want the key users to change what's necessary.

I'm firing up the drupal docker with my_theme mapped to /var/www/sites/all/themes/my_theme and the following is executed in the docker container:

# Install zen theme (needed for the sub-theme)
/usr/local/bin/drush -r /var/www en zen -y
# Install base modules
/usr/local/bin/drush -r /var/www en views, entity, pathauto, devel_node_access, backup_migrate, imce, link_css, jquery_update, ckeditor, farmmix -y
# Set our theme as default
/usr/local/bin/drush -r /var/www vset theme_default farmmix
# Disable old theme
/usr/local/bin/drush -r /var/www dis bartik -y
# Enable/Install permissions
/usr/local/bin/drush -r /var/www en views_ui, entity_token, views_content, admin_devel, color, contextual, dashboard, field_ui, file, image, list, locale, number, options, overlay, search, shortcut, taxonomy -y

This installs and enables the modules I need for development. What this does NOT do is create content types, blocks, views, etc that might be necessary for this site.

It would be ridiculous to recreate these essentials for the site each time a new instance is spun up (e.g: another developer starts to work on it). How can I put content types, blocks, views etc in git so if another developer checks it out, he can continue where I just left off?

Only backup and migrate helps?


texts: When and where should I replace tokens on a custom path for metatag context?

texts:
I have custom tokens defined in hook_token_info() and hook_tokens().  I need these tokens to populate metatag data for the metagag module on a custom path.  I have the context module installed as well.

The path routes to a callback that loads the object I need to pass to token_replace().

My question is when and where do I call token_replace() so the tokens are available to metatag context on page load?


texts:
I need hide a view when some GET param exists. It should be hidden like if you insert 'Global: Null' in contextual filter(It hides view if no results). This view placed in panel*

I tried to find the solution but failed. How to do this?


texts:
I have content type and I want to add contact button at the bottom of node page, but

I've problem so how I can add easy contact form that add node title at the message and When anonymous user goes node page called "Example 12" and after body text there is "Contact" or "Ask more" button and it goes form page.

After user left the message it goes admin content list and admins knows page where he/she goes that contact form.

Example I check page named "Example12" and there is ask more button.. I press that and I goes Ask more form and there is some fields and "You want to know more about example12" (example12 page title) and then I send that and it goes admin content list page so admins can contact me because I left mail in mail field.

So what is the best way to do it? Is there any good modules for that?


texts: How to automatically update field values for all translated nodes

texts:
I have original node which is in english. Then I have another node which is a translation of the original node. Both of these nodes have the same image field. When I update the value - change the image for the original node and save it, the change doesn't apply to the second node (the translation of the original node). How do I make the field changes sync across the translated nodes?

Thanks.


texts: How to display taxonomy term image in a view

texts: I have image field in taxonomy tags. Tags are term referenced in article content type, so now I want to show image field of my taxonomy term in my view. I have tried but I did not find any possible solution.


texts: How to install drush on a restricted shell access account? Media Temple shared environment

texts:
I'm working with a client that has a media temple server (gs)-gridserver. its a shared environment, but i do have access to the shell.

How would i go about installing drush for an account like this?


texts: How to add Tags to images being uploaded?

texts:
Is there a way to add tags to uploaded images (stored in vocabulary under admin/structure/taxonomy/tags/edit)

There is just alt and title fields as default at the moment....

I want users to add/ search tags that relate to images and not nodes (e.g. term reference)

I have found this module Taxonomy Images but it stops at D6 and I have D7

Ideally I would like something like this:


texts: "Cannot modify header information - headers already sent by (output started at codefolder\modules\user\user.module:1)"

texts:
i am using drupal 6, mysql 5.5 on apache 2.2 it is working fine.
but when i migrated my code on xampp1.7.3(contain apache2.2 and mysql 5.5).
it gives issue and error.

  warning: Cannot modify header information - headers already sent by (output started at codefolder\modules\user\user.module:1) in codefolder\includes\session.inc on line 99.
  warning: session_regenerate_id() [function.session-regenerate-id]: Cannot regenerate session id - headers already sent in codefolder\includes\session.inc on line 102.
   Blockquote

and after login pages containing urls like localhost/node/55 shows white pages. while without login it works fine.
while searching on google i found this issue might be due to header but i haven't used any header redirect in my  .tpl.php files.


texts: How to improve search results filtering on taxonomy

texts:
I would like to know the best way to filter drupal search results using taxonomy. I want users to be able to search for particular results from a particular taxonomy..this can be done to refine already searched results, or can be done from scratch.

Any module for Drupal 7 that does this well?


texts: Difference between Minimum cache lifetime and Expiration of cached pages

texts:
On Drupal Performance Page, under the fieldset Cache you have two options. One is Minimum Cache Lifetime and the other is Expiration of cached pages.

What is the difference between these two.


texts: How to add country phone number prefix in webform?

texts:
I have a webform, with a field for phone number.

I would like to have another select dropdown field before phone number, with country name and country phone number prefix.

Eg:
Singapore (65)
United Kingdom (44)
Venezuela (58)


texts:
I am new to Drupal 7, and I am trying to insert the form values in a database table. I used many ways to do that, but I am not getting successful result. What is wrong with the code I am using?

drupal_write_record('formtest', $data);
function form_test_form_submit($form, &$form_state) {
  $id = db_insert('formtest')
    ->fields(array(
      'First name' => $form_state['values']['firstname'],
      'Lastname' => $form_state['values']['lastname'],
      'Email' => $form_state['values']['email'],
      'Password' => $form_state['values']['password'],
      'Year of birth' => $form_state['values']['birthdata'],
      'Image' => $form_state['values']['fileimage'],
  ))
  ->execute();
  drupal_set_message(t('your messagees is added is sucessfule'));
}


texts: Can I use fewer modules for implementing my newsletter?

texts:
I came across a Drupal 7 site that combines following modules to send a newsletter for contact-form users (till now 6000 people subscribed): "Simplenews", "Mail system", "Mime mail", "simplenews rules", "variable email", "HTML mail" & "Rules".

I think this whole combination of 7 (or even more) modules is a wired solution.

Shouldn't only the modules "Newsletter' and "Webform" be enough?
If I move to a more minimalist solution, how could I save all the 6000 or so leads?


texts: Derivative images are generated in Private filesystem but the editor shows a non existent public folder path

texts:
Im saving my images into a private filesystem.
The derivatives are also generated in the same private filesystem.
When the images are uploaded, the thumbnails are displayed but after the node is saved and the node is selected to edit, all thumbnails don't show because the URLs are pointing to the public filesystem.
I new to Drupal and I want a work around this, i am using Drupal 9.2
I am not using any modules.
Are the derivative image URLs saved with the node in the database?
Or how can I redirect the node to point to the Private filesystem's location for the derivatives


texts: How do I troubleshoot a jQuery/AJAX issue?

texts:
On a current Drupal Commerce installation, I just started experiencing issues where a field is not updating after a jQuery click event.

When a user selects an option, the price typically updates for several of the products on our store. When adding the item to the cart, the correct price is shown. (While helpful on my end that the customer is being charged the right price, it's not great that they cannot see the right price until it is in the cart.)

Everything was working well. No updates were pushed for our distribution and added modules, but this feature is no longer working.

From the Chrome Console, I pulled the error msgs below. How do I troubleshoot? Should I just restore a backup?

ui.spinner.min.js:7 Uncaught TypeError: Cannot read property 'msie' of undefined
at ui.spinner.min.js:7
at ui.spinner.min.js:22

jquery.formalize.js:13 Uncaught TypeError: Cannot read property 'msie' of undefined
    at jquery.formalize.js:13
    at jquery.formalize.js:135
commerce_kickstart_product_ui.js:6 Uncaught TypeError: $(...).spinner is not a function
    at Object.attach (commerce_kickstart_product_ui.js:6)
    at Object.<anonymous> (drupal.js:76)
    at Function.each (jquery.min.js:4)
    at Object.Drupal.attachBehaviors (drupal.js:74)
    at HTMLDocument.<anonymous> (drupal.js:504)
    at c (jquery.min.js:4)
    at Object.fireWith [as resolveWith] (jquery.min.js:4)
    at Function.ready (jquery.min.js:4)
    at HTMLDocument.q (jquery.min.js:4)


texts:
I am using the Commerce Kickstart 2.x demo. When the guest checkout option is selected, the default guest email demo+1614916499@commercekickstart.com.
Is there a way to change what's displayed as default contact email for guest?


texts: Where does location cck module save the data?

texts:
I've gone through the code in modules/all/location/contrib/location_cck but am unable to figure out where this CCK field is storing the address data.

I guest that it's install file should have table fields to store geographic data like city, lat long etc. But it isn't there.

Edit: Ultimately I want to access all those location fields separately(beyond Views) when writing modules etc. For example I want to read postal code attached to a particular node for some analysis. That's why I'd like to extract location info about nodes.


texts: What linux user accounts should be created prior to Drupal 7 install?

texts:
When preparing to install Drupal 7 on a clean linux installation (Centos 7 in my situation), what linux user accounts should be created?

I ask this question because I seem to be having problems with file permissions or ownership when installing new modules with Drush.  When I do so I get an error like the following:

... /sites/all/modules exists, but is not writable. Please check directory permissions.

I only have 2 linux accounts on this system, root and myself, and typically run Drush as myself rather than root.  I have run 'Drush fp' to fix file permission problems, but this error persists.

So what linux accounts besides root should be created for use with Drupal and what should the user file permissions be?  Thanks


texts: How to get the paragraph information in a custom display suite code item

texts:
I want to add a custom field for a paragraph item in display suite,
but I don't know the name of variable.

I try a print_r($entity) and nothing is returned. How can I find out what the object name is?


texts: Replace UID in view tab with name on user profile page

texts:
I'm working on a Drupal 8 site. I made a custom page view displaying special content created by the user. The menu tab shows on the user profile correctly by using Pathauto to show the correct address on the primary user profile page using a pattern of: user/[user:field_full_name].
On the tab page created by my custom view, I can't get it to show the user name, only the user ID from the page view path: /user/%user/other-work
I would like the tab's page view URL to show the user's name instead of just the user ID. I already tried different patterns in Pathauto, but it doesn't seem to have that ability. Pathauto does work for fixing the default user page URL, but none of my custom views pages I added. Does anyone know if it's possible for a custom view page like mine to show the user's name instead of the UID in the tab's URL?


texts: Mollom captcha widget not showing up on a custom form

texts:
D7 + Mollom. I want my users to fill in captcha on a custom form every time they click a link like /file/123/download on my site. I'm trying to bend Mollom captcha to my needs but haven't had any success with it yet. Mollom public and private keys say they have been verified by Mollom server and are working all right even though my site is still at localhost. I also implemented hook_mollom_form_list() and hook_mollom_form_info($form_id) for my custom form and have set the form to be protected by Mollom in its settings. Yet I see no Mollom widget on my form. Here is my code:

//registering custom form path with hook_menu()
function MYMODULE_menu()
{
    $items = array();
    $items['file/%/download'] = array(
      'page callback' => '_MYMODULE_custom_form',
      'title' => 'My custom form',
      'page arguments' => array(1),
      'access callback' => TRUE,
      'type' => MENU_CALLBACK,
    );
    return $items;
}

//getting custom form
function _MYMODULE_custom_form($fid)
{
    return drupal_get_form('_my_custom_form');
}

//creating a form with Drupal Form API (here is a form with a submit button)
function _my_custom_form()
{
    $form['submit'] = array(
        '#type' => 'submit',
        '#value' => t('Test form submit button'),
        );

    return $form;
}

//implementing hook_mollom_form_list
function MYMODULE_mollom_form_list() {
   $forms['_my_custom_form'] = array(
     'title' => t('My custom form'),
   );
   return $forms;
}

//implementing hook_mollom_form_info()
function MYMODULE_mollom_form_info($form_id) {
   switch ($form_id) {
     case '_my_custom_form':
       $form_info = array(
                'mode' => MOLLOM_MODE_CAPTCHA,
                'elements' => array(),
                'mapping' => array(),
            );
       return $form_info;
       break;
   }
}

When I click links like http://example.com/file/123/download I see a form title "My custom form" and a submit button "Test form submit button" but no Mollom widget. Obviously I'm missing something but can't understand what exactly.


texts: How to create custom module for admin area in drupal 8

texts:
Sorry if this question is so basic, I'm new about drupal.

So far which I know, we can create custom module or page in drupal 8 so we can access it with http://www.oursite.com/custompage.

What I need? Is possible to create custom module or page which can show in admin area? In this case, I want to sync a lot of accounts from another system/web app to my drupal site so I don't need to create manually using "people menu" in admin area. Or is there any best way to do that?

Can anyone provide a helpful articles to accomplish this? Help would so appreciated.


texts: Styling the autocomplete dropdown to work with the up/down arrow keys

texts:
The following custom styling for drupal core's autocomplete dropdown works when hovering, but it is ignored when using the up/down arrow keys. (Currently, pressing the arrow keys only turns the text white.)

Does anybody know the secret to getting styles and keypresses working together?

#autocomplete li:hover, #autocomplete li:focus{
background-color:#428bca;
color:green;
}


texts: How do I automatically update database tables when changing custom entity fields

texts:
New Drupal Developer here.

I am currently working on a inventory management module for a friend. And I ran into a bit of a snag with Custom Entities in Drupal 8.

I have a custom "Customer" entity content type which stores various bits of information about the customer, first name, last name, a number which we assign each customer, etc...

When I added a new field post-module-install, after running update.php, cron, etc... The new field was never added to the existing SQL table.

I am wondering if there is something I'm missing, like a way to force update the database without having to manually add the new table.

Here is the new field I added.

$fields['l_number'] = BaseFieldDefinition::create('string')
        ->setLabel(t('L#'))
        ->setDescription(t('The Customer\'s L Number.'))
        ->setSettings(array(
            'default_value' => '',
            'max_length' => 8,
            'text_processing' => 0,
        ))
        ->setDisplayOptions('view', array(
            'label' => 'above',
            'type' => 'string',
            'weight' => -7,
        ))
        ->setDisplayOptions('form', array(
            'type' => 'string',
            'weight' => -7,
        ))
        ->setDisplayConfigurable('form', TRUE)
        ->setDisplayConfigurable('view', TRUE);


texts:
I have some taxonomy terms that have an image field in them. I am trying to get the value of the image field in my templates. How can I do this? The field's name is field_header_image.

I have this so far but it does not work..

$headerimg = field_view_field('taxonomy_term', $term, 'field_header_image');
print render($headerimg);

I'm guessing I need something else for taxonomy_term but I'm not sure what that should be.


texts: So this is my problem. I deleted a view for my drupal 5 site and have no idea to recreate it. I've tried to recreated the view but it's not the same what so ever. The view I deleted was for a video page. It displayed videos, from third-party sites. The view displayed the title and a thumbnail of the the embedded video. The view that I recreated only displays the video link and not the thumbnail too. I've tried altering the fields to display the thumbnails. But with no luck. Any Ideas?


texts:
I need some session verification code to be run on each request to Drupal. The most obvious solution that I have found was to use the EventSubscriber interface, and the KernelEvents::REQUEST event. However, it looks like this event is not fired when a cached page is displayed (though I did set the priority to 28, to bypass the dynamic page cache), which seems like a major issue when it comes to session verification.

I then tried another method: using the HttpKernel interface, as stack middleware, like the page cache itself, and as this page suggests.

However, this way the code appears to be executed before everything else, including access to session storage (not 100% sure). For example, this:

$uid = \Drupal::currentUser()->id();
\Drupal::logger('my_module')->info('Request for user: ' . $uid);

Outputs: Request for user: 0, for any user (including admin) and in any situation. The PrivateTempStore doesn't work either.

Which method can I use to always be able to execute code that has access to the current user's session and related storage?


texts:
I have a problem with one block in my website, recently I noticed that it gets overlapped by the others, not allowing to be seen correctly and to click the links in it, it's the partner block at the bottom right of this website: http://www.esnbologna.org/

Any hints on how to solve this problem?


texts: How to add a view tab to node edit form?

texts:
I have two node bundles: events and registrations. Registrations have an entity reference field pointing to a given event.
I have a view, that list registrations with  some event and registrant information and a contextual filter for given event. I would like to add this view as a tab to Event node edit form so, that it would list current registrations to given event.
I managed to display the view on the edit form easily by adding the view to form render array with event nid as an argument for the contextual filter, but not sure, what are the possible ways to add view to a node edit form as a tab.


texts: Text field will not save after moving it from commerce billing profile to account fieldset in checkout

texts:
I am having difficulty moving a text field from the commerce billing profile entity to the account fieldset on the checkout page. No matter what I do the text field is not saved after moving it back in the custom validate function. Is there something that I'm missing?

/**
 * Implements hook_form_alter() from checkout page.
 */
function example_form_commerce_checkout_form_checkout_alter(&$form, &$form_state, $form_id) {

  // Move phone number field from billing profile to account fieldset
  $form['account']['phone_number'] = $form['customer_profile_billing']['field_customer_phone_number'];
  unset($form['customer_profile_billing']['field_customer_phone_number']);

  // Declare custom validate and submit functions
  $form['buttons']['continue']['#validate'][] = 'example_checkout_form_validate';
  $form['buttons']['continue']['#submit'][] = 'example_checkout_form_submit';
}

/**
 * Custom checkout form validate function
 * @param type $form
 * @param type $form_state
 */
function example_checkout_form_validate($form, &$form_state) {

  // Move field back to billing profile
  $form_state['values']['customer_profile_billing']['field_customer_phone_number'] = $form_state['values']['account']['phone_number'];
  unset($form_state['values']['account']['phone_number']);
}

EDIT: I tried moving the text field back to commerce profile in a custom submit handler as shown below, but I still can't get it it work.

/**
 * Custom checkout form submit function
 * @param type $form
 * @param type $form_state
 */
function example_checkout_form_submit($form, &$form_state) {

  // Move field back to billing profile
  $form_state['values']['customer_profile_billing']['field_customer_phone_number'] = $form_state['values']['account']['phone_number'];
  unset($form_state['values']['account']['phone_number']);
}

I want to move this field, which is for the customer's phone number, on the checkout page for aesthetic purposes. In the current workflow the shipping address is shown first followed by the billing address. Since the phone number field is attached to the billing profile, it looks strange when "My Billing information is the same as my Shipping information." is check as shown below.

This is the last part of the checkout page redesign. I am so close to finishing it. Any help would be much appreciated.

Thanks
Paul

EDIT

I was finally able to figure this out with the help of Ryan Szrama and http://www.drupalcommerce.org/questions/3711/saving-customer-profile-field. Thank you guys.

function example_checkout_form_submit($form, &$form_state) {
  $order = $form_state['order'];
  $phone = $form_state['values']['account']['phone_number'][LANGUAGE_NONE][0]['value'];
  $po = $form_state['values']['account']['po_number'][LANGUAGE_NONE][0]['value'];

  $order_wrapper = entity_metadata_wrapper('commerce_order', $order);

  // get profile id
  $profile_id = $order_wrapper->commerce_customer_billing->profile_id->value();

  // load customer profile
  $profile = commerce_customer_profile_load($profile_id);
  if ($profile_wrapper = entity_metadata_wrapper('commerce_customer_profile', $profile)) {
    // set the value of the field and save the profile
    $profile_wrapper->field_customer_phone_number->set($phone);
    $profile_wrapper->field_customer_po_number->set($po);
    $profile_wrapper->save();
  }
  unset($form['account']['phone_number']);
  unset($form['account']['po_number']);
}


texts:
Ctools popup is not working for me. Sharing the effort i made. Any suggestion will be appreciated..

function my_test_menu()
{
$items = array();
  $items['my_test/page'] = array(
    'title'=> 'my test page',
    'page callback' => 'my_test_page_callback',
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
  );
 $items['mytest/%ctools_js/modal'] = array(
    'title'=> 'modal contents',
    'page callback' => 'my_ajax_test_page_callback',
    'page arguments'=> array(1),
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
  );
  return $items;
}

these are callback functions :--

//menu callback
function my_test_page_callback()
{
ctools_include('ajax');
ctools_include('modal');
ctools_modal_add_js();
    $build['paragraph'] = array(
    '#prefix' => '<p>',
    '#suffix' => '</p>',
    '#markup' => t('click on the button to show a cool modal'),
   );
$link = ctools_modal_text_button(t('Show a popup'), 'mytest/nojs/modal', t('Show a popup By clicking'),  'ctools-modal-ctools-sample-style');
$build['popup_link'] = array(
'#markup' => $link,
);
return render($build);
}

//ajax call back
function my_ajax_test_page_callback($js = NULL)
{
if($js)
    {
       ctools_include('ajax');
       ctools_include('modal');
    }
       $title = t('my cool popup');
       $build = array(
       '#prefix' => '<strong>',
       '#suffix' => '<strong>',
       '#markup' => t('Hello world! From a cool module'),
       );
return ctools_modal_render($title,$build);

}


texts: Create drupal commerce product with external script: problem with custom fields

texts:
I'm trying to create drupal commerce product from php script. I've used for this task sample function from commerce_examples module.

Everything is working well except two things: I can't add values to the custom datetime field field_valid (it has two values "datetime from" and "datetime to") and term reference to the category field field_category.

I can get category tid, but I don't know how to add value to the field.

Please help me with it, because I tried everything I could find in the Internet, but still didn't have any success.

I have array of product fields values

$extras = array(
    'sku' => 'stf_' . $value->id,
    'status' => TRUE,
    'uid' => $GLOBALS['user']->uid,
    'title' => $value->name,
    'price' => $value->pricecoupon,
    'start_time' => $value->start_time, // value: 2012-05-14 03:00:00
    'end_time' => $value->end_time, // value: 2012-05-14 03:00:00
    'category' => $value->category, // value: MyCategory
);

function product_example_create_product($product_type, $extras) {
    $form_state = array();
    $form_state['values'] = array();
    $form = array();
    $form['#parents'] = array();

    // Generate a new product object
    $new_product = commerce_product_new($product_type);

    $new_product->status = $extras['status'];
    $new_product->uid = $extras['uid'];

    $new_product->sku = $extras['sku'];
    $new_product->title = $extras['title'];
    $new_product->created = $new_product->changed = time();

    $price = array(LANGUAGE_NONE => array(0 => array(
        'amount' => $extras['price'] * 100,
        'currency_code' => commerce_default_currency(),
    )));
    $form_state['values']['commerce_price'] = $price;

    if(!empty( $extras['category'])) {
        // Get category term tid
        $term = taxonomy_get_term_by_name($extras['category'], 'catalog');
        $tid = term[1]->tid;
       // HERE I NEED TO ADD CATEGORY REFERENCE
    }

// HERE I TRIED TO ADD DATETIME FIELD
//  list($date_from, $time_from) = split('[ ]', $extras['start_time']);
//  list($date_to, $time_to) = split('[ ]', $extras['end_time']);

//  $form_state['values']['field_valid'] = array(LANGUAGE_NONE =>array(0 => array('value' => array('date' => $date_from, 'time' => $time_from), 'value2' => array('date' => $date_to, 'time' => $time_to))));

    // Notify field widgets to save their field data
    field_attach_submit('commerce_product', $new_product, $form, $form_state);

    commerce_product_save($new_product);
    return $new_product->product_id;
}

UPD: Here is solution

if(!empty( $extras['category'])) {
// TODO: check if correct tid was received and add default tid with message to manager
// TODO: Make workaround for multiple category instances
    $term = taxonomy_get_term_by_name($extras['category'], 'catalog');
    $form_state[ 'values' ][ 'field_category' ] = array(LANGUAGE_NONE => array(0 => array('tid' => $term[1]->tid)));
}

$form_state['values']['field_valid'] = array(LANGUAGE_NONE =>array(0 => array(
    'value' => $extras['start_time'],
    'value2' => $extras['end_time'],
    'timezone' => 'Europe/Kiev',
    'timezone_db' => 'UTC',
    'date_type' => 'datetime'
)));


texts:
I switched on Devel logging on site (shop on Drupal Commerce), went to Shop->Orders and saw that

3818.231 views_plugin_query_default::execute P A E
SELECT commerce_order.order_id AS order_id, commerce_order.order_number AS commerce_order_order_number, commerce_order.uid AS commerce_order_uid, commerce_order.created AS commerce_order_created, users_commerce_order.name AS users_commerce_order_name, users_commerce_order.uid AS users_commerce_order_uid, commerce_order.status AS commerce_order_status, 'commerce_order' AS field_data_commerce_order_total_commerce_order_entity_type FROM commerce_order commerce_order LEFT JOIN users users_commerce_order ON commerce_order.uid = users_commerce_order.uid LEFT JOIN recently_read recently_read_commerce_order ON commerce_order.order_id = recently_read_commerce_order.entity_id LEFT JOIN commerce_payment_transaction commerce_payment_transaction_commerce_order ON commerce_order.order_id = commerce_payment_transaction_commerce_order.order_id WHERE (( (commerce_order.status NOT IN (:db_condition_placeholder_0, :db_condition_placeholder_1, :db_condition_placeholder_2, :db_condition_placeholder_3, :db_condition_placeholder_4, :db_condition_placeholder_5)) )) ORDER BY commerce_order_created DESC LIMIT 100 OFFSET 0
default

2422.621 views_plugin_pager::execute_count_query P A E
SELECT COUNT(*) AS expression FROM (SELECT 1 AS expression FROM commerce_order commerce_order LEFT JOIN users users_commerce_order ON commerce_order.uid = users_commerce_order.uid LEFT JOIN recently_read recently_read_commerce_order ON commerce_order.order_id = recently_read_commerce_order.entity_id LEFT JOIN commerce_payment_transaction commerce_payment_transaction_commerce_order ON commerce_order.order_id = commerce_payment_transaction_commerce_order.order_id WHERE (( (commerce_order.status NOT IN (:db_condition_placeholder_0, :db_condition_placeholder_1, :db_condition_placeholder_2, :db_condition_placeholder_3, :db_condition_placeholder_4, :db_condition_placeholder_5)) ))) subquery

Is it normal that on site with 3000 items and 7000 orders it takes so much time to form orders view in admin interface?

Site is hosted on server, Xeon E5-2609x2 (2.4 Ghz), 16 Gb DDR-3 memory


texts: how to send muliple emails in drupal in same time

texts:
in my site when user submit a dination i want to send email to donor,charity and delivery service at same time(three different emails) in code and i want to kown how can i achieve that,below is the my mail seding function,i already tried call email function with 3 times with different keys for $key but that time emails are sending with out body content

 function zgRequestsdonor2_mail ($key, &$message, $params) {
  switch ($key) {
  case 'aftersubmit_donor':
    // Set headers etc

    $message['subject'] = t('email to donor');
    //$message['body'][] = t('Hello @username,', array('@username' => $params['username']));
    $message['body'][] = 'tyrtyrtyrtyty';
    break;
  }
}

calling it at

function zgRequestsdonor2_form_submit($form, &$form_state) {
  drupal_mail('zgRequestsdonor2','aftersubmit_donor',$donoremail, $language, $params = array(), $from = NULL, $send = TRUE);
}


texts: How to create a menu navigation on a Views page that uses contextual filters?

texts:
I have a projects content type and I want there to be a menu for each project that would have Project Overview, Project Details & Team Members.

So in Views I created a page at projects/ which would be the overview page that filters based on project title.

Then I have a page at projects/%/details, and another at projects/%/people.

So how would I either create a menu that I could put in the sidebar or somewhere that would work for any project, or maybe use tabs instead? Whichever is fine, but if you could teach me how to do both that would be cool.

I tried using the menu settings under Page Settings in Views, but I couldn't get it to work.


texts: Webform Validation - adding validation on a date field to be not greater than another date field entered in the same submission

texts:
Drupal 8 webforms
We have a procurement completion date and build completion date. Build completion cannot be earlier than procurement completion naturally.
I tried setting this up by adding the min date validation for build completion using the token below:

This gave me an error stating the field is recursively being called and it broke the webform.
Is using webform submission values token on the form being filled possible or am I going about this wrong?


texts: Is it possible to use a function which uses $node without the expense of node_load

texts:
In cases where $node is not available but I know the nid, is it possible to mimic $node rather than using node load. I would like to try and cut the expense of performing a full node load..

For example to find a nodes taxonomy by vocab:

  $nid = 1;
  $vid = 1;
  $node = stdClass();
  $node->nid = $nid;
  $terms = taxonomy_node_get_terms_by_vocabulary($node, $vid);

I have tried the above but it doesnt seem to work. I want to use the taxonomy_node_get_terms_by_vocabulary function but dont want the expense of having to use node_load to get the $node object


texts: I am trying to enable the jQuery UI module, but I am hitting with error

texts:
I am trying to enable the Jquery UI module in drupal 7, but I am hitting with error: The jQuery UI plugin is missing. Download and extract it to your jquery_ui module directory. (Currently using jQuery UI Not found)

I downloaded and extracted the plugin from the link into my Jquery_UI folder in sites/all/modules/jquery_ui. still I could not enable the module.


texts: How do i create complicated content type?

texts:
My apologies for bad english.

I want to create educational website with user generated content. Sort of like wikipedia. The problem is content is a little bit complicated.
It must have 4 tabs, which represent 4 stages of learning. Each individual tab must have guide (a basic content page with a text), a f.a.q. page, and a forum for users to open topics related to subject of learning and current stage.
I draw a markup for better undearstanding:

I tried to make it myself by creating a content type with a Field Group module and ended up with this:

Current problems are: a) guide on each tab is just a text but needs to be a title, which leads to page with a guide; b) have comments instead of forum under the tabs and no idea how to make it.

I would absolutely appreciate any help.


texts: Workbench Access field cannot be used for access control

texts:
I have set up Workbench Access and Workbench Moderation and it is working in creating revisions for the Main Page Content section but when I go to add additional fields using the Workbench Access control field checkbox, I cannot enable the field and a message displays

This field cannot be used for access control

How is it possible to allow a custom field to be added to access control?  I've enabled the correct content type, set up vocabularies and set the Access control fields with the node reference field from the content type.


texts: CKEditor plugin button/icon in config page but not on Add node?

texts:
I'm writing my own CKEditor plugin to insert text snippets and have turned it into a custom module to work with the CKEditor stand-alone module.

The plugin works on a static page that just has CKEditor linked locally.
The button and plugin checkbox show up on the CKEditor Profile
configuration page.
The button does NOT appear when I try adding or editing a node with a
CKEditor-enabled text box.

Complete code for the Drupal module:

function ckeditor_insert_view_ckeditor_plugin() {
   return array(
      'insert_view' => array(
         // Plugin name.
            'name' => 'insert_view',
            // Plugin description - it will be displayed in the plugins management section of the profile settings.
            'desc' => t('Plugin for adding Insert Views shortcode.'),
            // The full path to the CKEditor plugin directory, trailing slash included.
            'path' => drupal_get_path('module', 'ckeditor_insert_view') . '/plugins/insert_view/',
            // Plugin buttons definition (optional).
            'buttons' => array(
               'insert_view' => array('label' => 'Insert View', 'icon' => 'icons/insert_view.png')
            )
        )
    );
}

Complete code of plugin.js:

CKEDITOR.plugins.add( 'insert_view', {
    init: function( editor ) {
        editor.addCommand( 'insert_view', new CKEDITOR.dialogCommand( 'viewDialog' ) );
        editor.ui.addButton( 'View', {
            label: 'Insert View',
            command: 'insert_view',
            //toolbar: 'insert',
            icon: this.path + 'icons/insert_view.png'
        });
        CKEDITOR.dialog.add( 'viewDialog', this.path + 'dialogs/insert_view.js' );
    }
});

Things I've already considered:

Advanced Content Filtering is turned off for this CKEditor profile.
I've tried it with the CDN and with a local CKEditor library. Doesn't seem to make a difference.
I think I have all the paths set correctly, but would appreciate another set of eyes!

What might I be missing?


texts: $form_state->setValue() doesn't save value

texts:
I have an validate code:

public function validateForm(array &$form, FormStateInterface $form_state) {
    parent::validateForm($form, $form_state);

    $form_state->setValue('my_variable', $form_state->getValue('my_variable') + 1);
    $form_state->setRebuild();
}

And I previously set my_variable to 1 if it's NULL:

public function buildForm(array $form, FormStateInterface $form_state) {

    if($form_state->getValue('my_variable') == NULL){
        $form_state->setValue('my_variable', 1);
    }
...

I use ajax callback for form submission and the validation works fine. After click on submit button I display my_variable and I see 2 (before submission it's 1).

But when I hit the submit button again I see 2 again, instead of 3.
Also, when I re-load the page the data is missing (so it's get value 1 again).

How to prevail the value? It looks like I am operating on copy of $form_state instead of reference but I cannot write &$form_state (public function validateForm(array &$form, FormStateInterface &$form_state)) because it gives me an error (as it's not the correct declaration of validateForm method).


texts:
I just followed http://www.andypangus.com/drupal-7-adding-roles-to-users-dynamically to create a new content type. I am successfully able to create it, but when I uninstall the module, the content type is not getting deleted. I also cannot delete it from the admin interface; there is no delete option.

Why cannot I remove the content type? How should I remove it?


texts: Change Menu Item's links Dynamically, per page basis

texts:
I've been looking for this for a while, but found no solution.

What I want is: Whenever someone visits to a user's profile, say http://mysite.com/user/1 there should be an item available in Main Menu, with the link: http://mysite.com/custom_module/1

Here, I'll be dynamically changing the menu item's links based on the current page. How to achieve that?

Thanks.


texts: How to get webform field value in hook_webform_results_access

texts:
In webform 7.x-4.11 I use this :

if (webform_results_access($node)) {
    $actions['resend_app'] = array(
      'title' => t('Resend Appointment'),
      'href' => 'ical/' ,
    );
  }

I use it to add a "Resend Appointment" option (just as "resend email") when editing a webform.

I would like to add in the "href" some field value of this webform. How can I do that?


texts: Views: Using Pager With Single Node, Multiple Fields

texts:
I created a node, that has multiple images on it. I want to use this node as the "source" for a views page showing a gallery of images.

I am having a few problems, the first and most major, is that the pager does not work.

I presume that is because all of the images are coming from a single node.

The second problem is more aesthetic; the images are not spaced correctly, and are not distributed across the width. I am not sure how to fix this problem either.

Any help would be greatly appreciated.


texts: How to consistently redirect after saving on Add/Edit node form?

texts:
When creating a new node doing a $form['redirect'] seems to work consistently, but doing the same redirect when editing an existing node doesn't. The problem only occurs when the admin overlay is shown.

Is there any way around this?


texts: Show the latest post from multiple content types

texts:
I have three different content types like news, events, meetings. Using views i need to display only one post (the latest one) from each of this content type.

Created a view, filter criteria for all four content types selected....and stuck.


texts: How to change the system path of a taxonomy vocabulary to correspond a view

texts:
I'm using Drupal 8 and i want different vocabularies to be displayed by different views.
Each view should have a different path with a contextual filter but when i define my path on pathauto the alias will be pointed to the system path.

I know there's modules that solve this like Taxonomy Display and Entity Path but because i'm using version 8 i really can't afford these modules.

Can you help me to change the default system path of each taxonomy vocabulary to correspond to a custom view?

Thank you for reading


texts: Adjusting views breadcrumb behavior with default contextual filter present?

texts:
I have a view that displays news articles by year, with the year given as a contextual filter received via the URL.

When no argument is present, I have views set a default argument of todays date, so it will show all of the news articles for 2013 when someone goes to /news. If they go to /news/2012, it would display the 2012 articles.

I've noticed that views is setting the breadcrumb to include "News" and the path to the main view when no argument is present, AKA going to /news. Based on the URL path, it doesn't make sense to display a breadcrumb to the main news page. I can sort of understand why this happens. Since I'm essentially telling views that there IS an argument, it doesn't know that it shouldn't display a breadcrumb.

What is the best approach to handle this situation? I'd like the breadcrumb to appear only when the contextual filter is present. If I could just disable breadcrumb handling completely, I suppose I could use another module to set the breadcrumb manually based on how I want it.


texts: Unchecking "rebuild theme cache" caused site to break

texts:
I'm new to Drupal and I've unchecked the "rebuild theme cache" option on my Drupal 7 site, now the site only shows a blank white page when loading (no html returned when I view the source on Firefox). After turning on error reporting on index.php I get this error:

Fatal error: Cannot redeclare class InsertQuery in /var/webroot/database/query.inc on line 727

Does anybody know how to undo this? I'm assuming it's some row I need to modify in the Drupal database.


texts: How do I remove the page title only from the front page?

texts:
I have created a basic page and assigned it to the front page. Now I would like to remove the title shown in the front page.

How can I achieve this?


texts: Order quantity increment condition for payment method

texts:
I need to set order increment quantities in my Commerce 2 website. The website has two stores: retail and wholesale. Customers who are shopping in my "retail consumers" store must have increments of 6 products in their cart in order to check out (6, 12, 18, 24, etc). Customers in my "wholesale consumers" store must have at least 4 products in their cart in order to check out (4, 8, 12, 16, etc).
My plan is to add a custom Condition that can be used for the two payment gateways that will be used in the stores (one for each store). That custom Condition would allow me to designate an increment value for the product quantity for each gateway. "Make this gateway available if the cart contains an increment of 6 products".
I recently created a similar plugin for product quantity minimums in the cart, and I think I can re-use most of that code with a few adjustments. I am just not sure how to factor in the incremental requirement. It would be acceptable to hard-code the increments of 6 if that is the best/easiest way to do it; I could then create two separate condition plugins, one for 6 and one for 4.
Below is the Condition plugin code I have so far:
<?php

namespace Drupal\order_total_quantity_increments\Plugin\Commerce\Condition;

use Drupal\commerce\Plugin\Commerce\Condition\ConditionBase;
use Drupal\commerce_price\Calculator;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Form\FormStateInterface;

/**
 * Provides the quantity increment condition for order items.
 *
 * @CommerceCondition(
 *   id = "order_total_quantity_increments",
 *   label = @Translation("Quantity Increment"),
 *   display_label = @Translation("Limit by quantity increments"),
 *   category = @Translation("Products"),
 *   entity_type = "commerce_order",
 *   weight = 10,
 * )
 */
class OrderTotalQuantityIncrements extends ConditionBase {

  /**
   * {@inheritdoc}
   */
  public function defaultConfiguration() {
    return [
      'increment' => NULL,
    ] + parent::defaultConfiguration();
  }

  /**
   * {@inheritdoc}
   */
  public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
    $form = parent::buildConfigurationForm($form, $form_state);

    $increment = $this->configuration['increment'];

    if (isset($increment) && !isset($increment['number'])) {
      $increment = NULL;
    }

    $form['increment'] = [
      '#type' => 'number',
      '#title' => t('Increment'),
      '#default_value' => $this->configuration['increment'],
      '#min' => 1,
      '#required' => TRUE,
    ];

    return $form;
  }

  /**
   * {@inheritdoc}
   */
  public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
    parent::submitConfigurationForm($form, $form_state);

    $values = $form_state->getValue($form['#parents']);
    $this->configuration['increment'] = $values['increment'];
  }

  /**
   * {@inheritdoc}
   */
  public function evaluate(EntityInterface $entity) {
    $this->assertEntity($entity);
    /** @var \Drupal\commerce_order\Entity\OrderInterface $order */
    $order = $entity;
    $increment = '0';
    foreach ($order->getItems() as $order_item) {
      $increment = Calculator::add($increment, $order_item->getQuantity());
    }

  }

}

I believe I have to modify the last part of the code (below) or add something after it.
  public function evaluate(EntityInterface $entity) {
    $this->assertEntity($entity);
    /** @var \Drupal\commerce_order\Entity\OrderInterface $order */
    $order = $entity;
    $increment = '0';
    foreach ($order->getItems() as $order_item) {
      $increment = Calculator::add($increment, $order_item->getQuantity());
    }

  }

Can anyone please provide me with a direction to go in/guidance on how I should modify the code to meet my objective?


texts: Aligning the Article/Node Title next to image

texts:
I've been working on a theme just in my spare time and I'm trying to style the way the article/node is displayed. Currently its simply formatted to:

title
submitted info
image
Short summary/description
read more / login

I want the field layout to be somewhat like the one they use on the League of Legends website (I believe that site is using Drupal)I want to make it so they layout is basically like this part of the site:

However I am unsure how to do this and what files I need to edit, I've been styling the rest of the site using responsive.css however I'm not sure how to change the layout and style it all.

Any help with this would be much appreciated.

Thanks,
Ben


texts: Procedure to import a site to Acquia Dev Desktop

texts:
So, I'm looking for a painless procedure to import a site into Acquia's Dev Destkop on Windows

Theoretically, the procedure should be

Install clean drupal site (clean db and codebase)
Create Database and user for site to be migrated with phpmyadmin
Copy sites folder to new drupal root
Configure settings.php file to match new server environment.
Run Update.php script

The problem is I get a PDOException: SQLSTATE[HY000] [1045] Access denied for user 'psr_admin'@'localhost' (using password: YES) in drupal_get_installed_schema_version() (line 155 of C:\Users\Nick\Sites\devdesktop\psr_final\includes\install.inc).

This is the procedure I've followed on a number of installations, and I am wondering what I am doing wrong, or which aspect of the configuration is incorrect. I've even gone into phpmyadmin and re-created the database user and password to make sure that all the settings are correct. So, can someone tell me what I did wrong, or point me to the correct way to import a site into Acquia's dev desktop?


texts: How can I force users to provide a reason when cancelling their accounts?

texts: I would like to force users to provide a reason for cancelling (a text area would be ideal) their accounts.  I have had several users close their accounts on one of my sites recently and I would like to know why.


texts: Likeit module count for an entity refrence field in drupal 8

texts:
I have Enabled the Like it! module for a content type called "recipe" on my website. I am able to get the value of like count for the recipe in node--recipe.html.twig. Now, in the same content type, I have an entity reference field for recommended recipes. I need to render the value of count for recommended recipes in my node--recipe.html.twig file. what changes are required and in which files please if anyone knows then help? I have very little idea about modules.

Using Drupal 8.5

  content['_field_layout']['content']['likeit']['#count']

gives me the value of count for recipe.


texts: Dependency injection for FormElement #process callback

texts:
Is there any way to inject container services into FormElement callbacks like '#process'? Or do I need to call \Drupal::container()->get(..)?

I noticed https://www.drupal.org/docs/8/api/services-and-dependency-injection/dependency-injection-for-a-form, but this is for forms, not for form element types.


texts:
I'm using Omega 7.3x to theme my site, and at current, all the page headers are

[Page Title] | [Site Name]

but I'm trying to bring back google analytics reports into the site so the admin can see a list of the most active pages etc, except all the reports have the same pattern, it makes reading the report more difficult

eg, the report looks like

My Account | My Website
Fixtures | My Website
Events | My Website
Contact | My Website

I want to either remove the Site name from the page title, or just so that Google Analytics doesn't pick it up, I assume the latter is better to do in terms of SEO etc, how do I do that?


texts:
I'm trying to get a two tiered pricing structure into my store. Essentially I need every product to have two prices. There's the main price but there's also a secondary price that get's triggered if the customer has more than 14 products in their cart. I can't do an across the board discount, it has to be specific prices per product.

Say product one has a main price of $20 but a hidden secondary price of $15 and product two has a main price of $50 but a hidden secondary price of $30. This will be defined on the product itself. It's all arbitrary pricing set for every product.

I figured out how to set a rule where 14 products will trigger it but I can't work out how to add a secondary price to a product then activate that price.


texts: Show message at every page regardless page content

texts:
I need to show some message for user for every page at my site.

I've tried Rules action "Content is viewed" and I see message, but only when some node is displayed.
I don't see message when I open User page, or page with Taxonomy term, or some View page without nodes as content.

How can I show message at every page of my site regardless page content?
(Rules or Hooks or ...?)


texts: Why doesn't Drupal use my block.tpl.php?

texts:
I want my Drupal 7 theme to use a custom block.tpl.php for my navigation bar (Defined: regions[navigation] = Navigation bar). So I copied block.tpl.php from the block module to my theme directory and tried to give it different names (following different guides on the web). None of them seemed to work.
Then I wanted to make sure it was a naming problem so I changed the name back to block.tpl.php and changed its contents (removed the h2-tag for the title). I reloaded my site but nothing happened so there must be another problem.

Any ideas on how to fix this?

Thank


texts: Logging out user by modifying database directly?

texts: Is there a way to log out a user by just modifying the drupal database?


texts: How to set validation error for specific subfield of the paragraph type?

texts:
I've got paragraphs type with two fields which I've added as a field into my vocabulary.

I've added validation function (#validate) into $form using hook_form_FORM_ID_alter where I'm validating values of these fields, however when I'm using the machine name of the paragraph field, all widgets are highlighted. My aim is to highlight only the one which fails.

The structure of that paragraph field (field_sor_rule) is like:

// var_dump($form_state->getValue('field_sor_rule'));
array (size=3)
  0 =>
    array (size=3)
      'subform' =>
        array (size=2)
          'field_sor_rule' =>
            array (size=5)
              0 =>
                array (size=2)
                  'value' => string '1' (length=1)
                  '_weight' => string '0' (length=1)

I've tried already referencing it as:

$form_state->setErrorByName("field_sor_rule[0][subform][field_sor_rule][0]",
  t('Please enter a valid value!'));

and:

$form_state->setErrorByName("field_sor_rule_0_subform_field_sor_rule_0]",
  t('Please enter a valid value!'));

but without success.

What would be a valid syntax?


texts:
I will soon start building a new reasonably large site, that will be presented to the end-user as several different sites. Different domains will map to different sections within the site, and will also have different themes.

How should I implement the "multi-theme"?

I'll be posting some ideas of my own, which I would love some feedback on, but would also very much like to hear other suggestions.


texts: How to configure a module after installation

texts:
In my Drupal 6 website there are a bunch of modules. What is the simplest way to configure these modules? Also I am not sure of where their settings are? If there is a simple link that can be invoked to configure them , that will be awesome. In this case its the ctools module.
I am not looking for http://www.sitename.com/admin/by-module neither the Site building has the module.

Thanks


texts: Redirect user based on role and node content

texts:
I want to redirect a user when they login based on what role they have and whether they have created a node of a type.

So if the user has administrator role, direct user to admin url
else if
the user has role list_user, check if user has content of type new listing, if they don't, direct them to create node listing if they do have created node of type listing, direct them to profile.

I have this set up in separate rules but I'm sure it will work better and faster by just having one php block of code in the template.php

My only problem is, I don't know php and everything I've tried doesn't work very well or not at all.

Any help would be appreciated.


texts: I have Created a form to upload images, where i should display error message if i upload more than 3 images and should disable submit button to delete already uploaded image if i want to upload more images


texts:
I'm trying to automatize an install of CiviCRM and Drupal, but I'm getting so many errors! (Using PHP 7, Drush 8, Drupal 7, CiviCRM 4.7.18)

CiviCRM has a Drush extension, which calls function module_enable(array('civicrm'))

However, Drush 8 (which says is compatible with D6, D7 and D8) throws Undefined function.

I would like to know if I should downgrade my Drush 8 or what?
Can I fix this error in some way?

These are the errors I get.

Error: Call to undefined function module_enable() in drush_civicrm_install() (line 367 of /root/.drush/civicrm.drush.inc) #0               [error]
phar:///usr/local/bin/drush/includes/command.inc(422): drush_civicrm_install()
#1 phar:///usr/local/bin/drush/includes/command.inc(231): _drush_invoke_hooks(Array, Array)
#2 phar:///usr/local/bin/drush/includes/command.inc(199): drush_command()
#3 phar:///usr/local/bin/drush/lib/Drush/Boot/BaseBoot.php(67): drush_dispatch(Array)
#4 phar:///usr/local/bin/drush/includes/preflight.inc(66): Drush\Boot\BaseBoot->bootstrap_and_dispatch()
#5 phar:///usr/local/bin/drush/includes/startup.inc(458): drush_main()
#6 phar:///usr/local/bin/drush/includes/startup.inc(365): drush_run_main(false, '/', 'Phar detected. ...')
#7 phar:///usr/local/bin/drush/drush(114): drush_startup(Array)
#8 /usr/local/bin/drush(10): require('phar:///usr/loc...')
#9 {main}.
Error: Call to undefined function module_enable() in /root/.drush/civicrm.drush.inc on line 367 #0 phar:///usr/local/bin/drush/includes/command.inc(422): drush_civicrm_install()
#1 phar:///usr/local/bin/drush/includes/command.inc(231): _drush_invoke_hooks(Array, Array)
#2 phar:///usr/local/bin/drush/includes/command.inc(199): drush_command()
#3 phar:///usr/local/bin/drush/lib/Drush/Boot/BaseBoot.php(67): drush_dispatch(Array)
#4 phar:///usr/local/bin/drush/includes/preflight.inc(66): Drush\Boot\BaseBoot->bootstrap_and_dispatch()
#5 phar:///usr/local/bin/drush/includes/startup.inc(458): drush_main()
#6 phar:///usr/local/bin/drush/includes/startup.inc(365): drush_run_main(false, '/', 'Phar detected. ...')
#7 phar:///usr/local/bin/drush/drush(114): drush_startup(Array)
#8 /usr/local/bin/drush(10): require('phar:///usr/loc...')
#9 {main}
Error: Call to undefined function module_enable() in drush_civicrm_install() (line 367 of /root/.drush/civicrm.drush.inc).
Drush command terminated abnormally due to an unrecoverable error.

Changing it to drush_module_enable() ends in another error:

Drupal\Core\Extension\MissingDependencyException: Unable to install modules civicrm due to missing modules civicrm. in                     [error]
/opt/compucorp/core/lib/Drupal/Core/Extension/ModuleInstaller.php:85
Stack trace:
#0 /opt/compucorp/core/lib/Drupal/Core/ProxyClass/Extension/ModuleInstaller.php(83): Drupal\Core\Extension\ModuleInstaller->install(Array,
true)
#1 phar:///usr/local/bin/drush/commands/core/drupal/environment.inc(131): Drupal\Core\ProxyClass\Extension\ModuleInstaller->install(Array,
true)
#2 phar:///usr/local/bin/drush/commands/core/drupal/environment.inc(198): drush_module_install(Array)
#3 /root/.drush/civicrm.drush.inc(367): drush_module_enable(Array)
#4 phar:///usr/local/bin/drush/includes/command.inc(422): drush_civicrm_install()
#5 phar:///usr/local/bin/drush/includes/command.inc(231): _drush_invoke_hooks(Array, Array)
#6 phar:///usr/local/bin/drush/includes/command.inc(199): drush_command()
#7 phar:///usr/local/bin/drush/lib/Drush/Boot/BaseBoot.php(67): drush_dispatch(Array)
#8 phar:///usr/local/bin/drush/includes/preflight.inc(66): Drush\Boot\BaseBoot->bootstrap_and_dispatch()
#9 phar:///usr/local/bin/drush/includes/startup.inc(458): drush_main()
#10 phar:///usr/local/bin/drush/includes/startup.inc(365): drush_run_main(false, '/', 'Phar detected. ...')
#11 phar:///usr/local/bin/drush/drush(114): drush_startup(Array)
#12 /usr/local/bin/drush(10): require('phar:///usr/loc...')
#13 {main}


texts: og_members block & og_nodes block won't display content

texts:
OG Version: 7.x-1.x-dev

My problem is that I can't get the og_members block & og_nodes block to show up under a group page.

Breakdown of my process:

A fresh install of D7, necessary modules
Created a new Content Type: Country: Specified as "Group type", "Not a group content type".
Add a new country: "England".
Createt a new Content Type: News: Specified as "Not a group type", "Group content type".
Add a News, title "Hello World", select England in "Group audience".
In Views page, I add block display for og_members, og_nodes. (All use default setting, no modification to the Views)
Assign og_members block, og_nodes block to sidebar left. (Bartik)
I go to "England" page, og_members block not show up, og_nodes block shows me "There is no content in this group."

I am pretty sure that the views setup correctly, as I pass the gid into the live preview, it does show the result. (See screent shot)

But the block just can't show up in a group page. I am guessing in the page, gid not passed to the block or what?

Am I missing any steps?

Thanks in advanced!!

Update: I found the solution by enabling the OG context module.


texts:
I would like to add a class to menu that shows how many items are in that particular level.  I.E.

1

2

3

4

5

What's the best way to do this?

I've looked at theme_menu_tree but the tree is already rendered html by that point so there is no easy way to count the number of items.


texts: Refresh page only for flagged node author

texts: I'm trying to refresh page for only the flagged node author with rules and views_nodejs. What is the right rule configuration to make this happen?


texts: Linking slideshow thumbnail to slideshow views content

texts: I have a view containing pictures from a content type "Slideshow". When I click the Slideshow title in a view containing the slideshows, it takes me to the slides from that slideshow. However, I want to get rid of the title and be able to click the picture instead of the title so I can do the same thing. Could you please tell me how I could do that?


texts: Multiple field Settings not appearing on an entity referenced field

texts:
I have a content gallery with a multiple selection entity referenced field to a biblio content. I added the image field to the biblio. Created a view for the gallery, and I'm able to display all the images form the referenced entity.

But for the gallery to work, I need the first image to display only, and when user selects an image a popup appears.

What I'm missing is for the first image to appear only.when configuring the entity referenced field, the multiple field settings is not appearing. Is there another way to do the following or am I missing something?


texts:
I'm working outside the area of what I know about Drupal. We're looking at using feeds importer to migrate a number of nodes. However, I didn't see anything in the documentation about its ability to grab fields attached to those nodes. Can it? How do I configure it to do so?

We're using node export currently, which works well, but is tedious since we're doing it one-by-one.


texts: How to setup Page Cache to work with the Flag Module and Views?

texts:
I have a Site where Views are used to display flagged Nodes.
When i turn on Cache Pages for anonymous Users, the anonymous Users only see the change in the Views until the cache is cleared. (If logged in no problem). What is the best Way to deal with this caching issue. I would prefer that all pages with views where item flags are updated would be recached. Is this possible ?


texts: With states, how to uncheck a disabled checkbox, but not check it when it becames enabled?

texts:
I have a Form API checkbox that can be enabled and disabled by another ("parent") one:

$form['my_checkbox']['#states'] = array(
  'enabled' => array(
    ':input[identifier="parent"]' => array('checked' => TRUE),
  ),
);

Works like a charm, but now I want it to get cleared if it is dizabled. So I made my code look like this:

$form['my_checkbox']['#states'] = array(
  'enabled' => array(
    '[:input[identifier="parent"]' => array('checked' => TRUE),
  ),
  'unchecked' => array(
    ':input[identifier="self"]' => array('disabled' => TRUE),
  ),
);

Sadly, this also automatically checks that checkbox when it becomes enabled, and that's not what I want - I want to give my user an option, but not suggest him to check that field at all.

Can this "one way" action be achieved with '#states'? If so, how? Or is it always two way deal, and there is no option to uncheck on disabling without checking on enabling?

Note: I tried to use both disabled and enabled of self, and checked & unchecked of parent, with the same results.

I know I can achieve it with behavior, that's how I have it done now, but states api is there to avoid behavior's complexity and my use case seems pretty simple.


texts: Inconsistent behavior with user_logout function

texts:
For a drupal 8 site, I have a custom function that does the following:
It logs out the user and sends them to an external url
Inside the controller CustomController, I have:
function custom_logout(){
 if (\Drupal::currentUser()->isAuthenticated()) {
    user_logout();
    return new TrustedRedirectResponse('https://example.com');
 }
}

In the routing.yml
customl.clogout:
  path: '/customlogout'
  defaults:
    _controller: '\Drupal\user\Controller\CustomController::custom_logout'
  requirements:
    _user_is_logged_in: 'TRUE'

When I visit the /customlogout for the first time it logs me out of Drupal and redirects me to example.com. If I revisit my site and login in again, and repeat the process it still redirects me to example.com but when I check my site I am still logged in. I am wondering why this happens? I can still logout using /user/logout though
Thank you


texts:
CKEditor do not work on one specific theme, it works fine in the back-end and also when I switch the theme.

When I look the sources, I get the JS & CSS, ckeditor class on textarea but not the injected code that CKE add under each textbox with id="cke_edit-body".

What can be the sources of the problem?

I know it's not jQuery, I found similar issues but they were provoked by a custom jQuery update, I use 1.3.2


texts: How can I expose a view with date filter?

texts:
I have a view and am listing a bunch of data from different content type .

What i need is , i have to list the data according to the date field given . That

is i have to filter the date in between two dates , Is this possible ?

WHAT I HAVE TRIED

I used the exposed filter as follows :

The problem of this filter is  i have to manually enter the date in date field .
can i have data field which can select the date as in datepicker ?


texts: Umlauts grouped in summary (U and Ü, A and Ä etc)

texts:
I faced the problem with summary attachment which includes umlauts like: U and Ü, A and Ä; O and Ö etc. For example if two nodes starting with letters U and Ü

Umlauts
Ümlauts

only U letter will be displayed in summary. In case when some of nodes starting only with Ü, this letter Ü in correctly displayed in summary, problem appears when nodes have both U and Ü as capital letters.

Later I figured out that it's caused by GROUP BY query part

SELECT SUBSTRING(node.title, 1, 1) AS title_truncated, COUNT(node.nid) AS num_records
FROM node node
GROUP BY title_truncated
ORDER BY title_truncated ASC

Nodes with first U and Ü letters are treated were treated as U. How can I manage this problem?


texts: Bootstrap dropdown parent link not clickable

texts:
This is the first drupal project i'm working on and i'm having the following problem.
I have my dropdown menu set up as followed:

The problem is that the parent link "Materialen" is not clickable while the children are.
What should i change to be able to click the parent link?


texts: Twig: "for" does not display variable content without first displaying all variable content

texts:
I have found a very strange behavior.

My variable related_nodes contains a list of nodes. How it is displayed by Kint:

related_nodes array(10)
'#sorted' => boolTRUE
'#pre_render' => array(1)
'8' => array(5)
'10' => array(5)
'11' => array(5)
'12' => array(5)
'13' => array(5)
'14' => array(5)
'15' => array(5)
'16' => array(5)

If I first display the content the variable {{ related_nodes }}, it displays this all related nodes and then them one by one in Divs (with loop index before):

{{ related_nodes }}
            {% for rel_node in related_nodes[2:] %}

{{ loop.index }} - {{ rel_node }}

            {% endfor %}

But when I remove the first display of the variable: {{ related_nodes }}, it does not display related nodes one by one in Divs (it displays only the loop indexes):

        `{% for rel_node in related_nodes[2:] %}

{{ loop.index }} - {{ rel_node }}

        {% endfor %} `

I also have 8 errors like this:
"   Notice: Undefined index: title in template_preprocess_node() (line 616 of C:\Users\Oksana\Documents\sites\drupal2\core\modules\node\node.module)" when the {{ related_nodes }} is removed.

When I removed the slice [2:], it did not help.

Is there any need to pre-load a varible before I can iterate in it with the twig 'for'? Or what can be a reason for such behavior?

I need to remove this {{ related_nodes }} because it displays all vertically without formating in columns.

Drupal version: 8.5.3.


texts: Show a region outside page tpl or check node type to show it

texts:
I'm developing a new custom theme and I need to show a region of the theme only in a specific sections of the site.

I tried looking about how to render a region outside the page template, but I didn't found anything.

Now, if it is possible, how can I do that?

If isn't possible, how can I check if a node is generated by a view from the Views module from the page template?
So I could show the region from the correct place when I want to.

I hope my question is clear enough.

Thanks in advance,
Mat.


texts: How can I use Drush 8 command to enable the site set up bin the Acquia DevDesktop to online mode?

texts: I forgot to put the site back online when I'd finished updating the site. How can I use Drush command to enable the site to online mode?


texts: Can't get data from drupal_http_request result

texts:
I'm requesting a zip file from a remote location, and I'm getting some strange affects here. Here is a snippet:

$result = drupal_http_request($serviceUrl, $options);
    $file = $result->data;

    dpm($result, 'file result'); //returns the object, and I can see $result->data is a string of characters
    dpm($result->data, 'data'); //But, this is empty
    dpm($file, 'file'); //This is also empty
    dpm($result, 'file result'); // Still shows me the object with $result->data

The http request works fine as it returns with a code 200

I want to use it as follows (example):

temp_filename = "my_zip.zip";
$zip_file = fopen($temp_filename, "w+");
fwrite($zip_file, $file); //$file is $result->data, but is empty.
fclose($zip_file);

Anybody got an idea why I can't get $result->data?

The code is inside an object method, not a standard PHP function. Not sure if that has anything to do with it.

Also worth mentioning that I can read $result->code and $result->status_message with no problems.


texts: After restoring, incorrect database credentials are used

texts:
I am trying to get a local drupal environment up and running using an sql dump from a production environment. I am attempting to follow instructions from drupal's documentation.

So far, from our production server, I went ahead and ran drush sql-dump > prod_drupal_backup.sql. Then, I used scp to pull the prod_drupal_backup.sql file from the production server.

On my local machine, using MAMP, I created a database (prod_drupal, same as the database on the production server) and gave a user, admin, access to the database. I went ahead and pulled down the codebase and created a fresh Drupal instance. During this set up, I gave Drupal the admin credentials to connect to the database and had a fresh site up and running.

With a backup, I was ready to restore the database using the prod_drupal_backup.sql SQL dump file. So I went and ran /Applications/MAMP/Library/bin/mysql -uroot prod_drupal < ~/Desktop/db_backup.sql. After this completed, I checked the database via MAMP's localhost:8888/phpmyadmin. The prod_drupal database had the correct data in it. So then I went to the website (localhost:8888) and saw what I wanted, the login screen with all of our styling and everything. When I logged in using one of the accounts registered for the site, it thrown the The website encountered an unexpected error. Please try again later. error.

When I look at my MAMP sql error logs in mysql_error.log, I see errors like access denied for user 'mikesmith@localhost'. This makes zero sense because Drupal is supposed to be connecting to the database with admin, not mikesmith. The way Drupal is trying to connect to the database doesn't match what's in the settings.php file.

What am I doing wrong?

I am using MAMP Pro 5.5.1 and PHP 7.2.21, if this makes any difference.


texts: Access denied when trying to import single configuration item

texts:
I am using Drupal 8.9.2 and trying to import a view using the Configuration Management UI in the admin. I did this with no issue importing the view from my local dev environment to our dev server, but when I try to do the same thing on our test server, I get "Access Denied".
The way I did this was by going to my local environment and going to Configuration > Development > Configuration synchronization > Export. Then choosing "Single Item". Under "Configuration Type", I chose "View" and then selected my view. I then copied this code and went to my dev server and went to Configuration > Development > Configuration Synchronization > Import and chose "Single Item" and chose "View" for "Configuration type". I pasted my code in and clicked submit and my View was successfully imported and all was well. Now when I do this exact same process on my test server, when I get to the part where I submit my pasted code and click submit, I get:

Is there a specific directory that I must not have access to on the server? Or Drupal doesn't have access to on the server? I'm not sure what happens behind the scenes during this type of import process. In my settings.php I have this for the config sync stuff:
$config_directories['sync'] = '../config/sync';

And I checked that directory and it does have read/write permissions. Is that even the directory I need to check as far as permissions go for a single item config import?


texts: Ajax in blogForm: Form being submitted more than once

texts:
I'm currently building a Block Plugin for Drupal 8.
Within the blockForm() is an autocomplete field which additionally uses an AJAX callback after the autocomplete is finished.

In code it looks similar like this:

public function blockForm($form, FormStateInterface $form_state) {
  $form['field_foo'] = array(
    '#type' => 'entity_autocomplete',
    '#target_type' => 'node',
    '#ajax' => array(
      'callback' => array($this, 'fooAjaxCallback'),
      'event' => 'blur',
      'wrapper' => 'additional_fields'
    ),
  );

  $form['additional_fields'] = array(
    '#type' => 'fieldset',
    '#title' => t('Additional fields based on autocomplete'),
    '#prefix' => '
',
    '#suffix' => '
'
  );

  return $form;
};

public function fooAjaxCallback($form, FormStateInterface $form_state) {
  return $form['settings']['additional_fields'];
};

What I want to achieve is to load additional form elements based on the autocomplete selection.

When using the autocomplete multiple times (searching for node one, changing to node two,..) the #ajax part is being fired each time the autocomplete changes (which is absolutely fine and a wanted behavior).

Submitting the block form after using the autocomplete multiple times leads to submitting it several times (exact: the amounts of #ajax runs from autocomplete field) but with different form states, only the last run will create a block with the changed values.

Any idea how to solve the problem?


texts: How can I include standard bits of text in a node, depending on the node location or a particular term?

texts:
I have a product page that is mostly original content, however I would like to include a block of text that is included on similar nodes. Eg, I have several pages for hotels in London, so I would like to include a block of text called 'About London', which then carries a couple of paragraphs about London.

I assume that this could be made to happen based on the node's Location or for a particular term attached to the node, but I don't know the best way forward with what I'm trying to do.


texts: How can I redirect the users after confirmation basing on the roles they have?

texts:
I have two type of users, and I have created two types of registration forms for each role. I want to redirect the users to different pages, once they get the email confirmation according to their roles.

For example:

user1, with the first role, must be redirected to page1
user2, with the second role, must be redirected to page2

I think I can achieve this feature using the Rules module, but I don't know how to do it.

Can you tell me how can I implement it?


texts: Indexing the term of unpublished entities

texts:
I have a views of unpublished contents of content-type X, which has the Term Y.

It works fine with published content but a thing that I noticed is that if I unpublished a content that has a taxonomy term, in Views it loses the term associated with it, therefore I cannot filter my list based on taxonomy term anymore.

I also found Taxonomy Entity Index module but it doesn't work at all.

Also a related issue on drupal.org

Is there any workaround for this?


texts: Change description of dynamically added field

texts:
I'm trying to change the description of fields in a from (/node/add/content_type).

I found out it is possible to change the description with this code:

function hook_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
  if ($form_id == 'node_thema_form') {
    $markDownDescription= 'custom description';
    $form['field_name']['widget'][0]['#description'] = \Drupal\Core\Field\FieldFilteredMarkup::create(t( $markDownDescription . $form['field_txt_lesinhoud']['widget'][0]['#description']));
  }
}

This works great on existing fields, but via Paragraphs I add new fields since they are loaded using AJAX they for some reason don't get the new description. Is there any way to do a new form alter to the new fields?

Thanks in advance


texts: How to block Webform spam based on keyword strings?

texts:
Short Version: I would like to block Webform submissions that contain strings e.g. mail.ru in the webform textarea field.

Recently I am seeing a lot of fake webform submissions. I am already using honeypot contrib module and I have added quite a number of IP addresses to the server firewall. However there is still some spam coming through. For now I don't want use Captcha. Luckily those spammers always using recurring pattern e.g. same domain name.

How I can automatically block submission that contain certain strings? Using the rules + webform_rules module and Regex doesn't allow me to choose the Webform email field as data selector. selected-webform:0 doesn't look valid. What's the right way to block webform spam?

{ "rules_blocking_fake_registration" : {
"LABEL" : "Blocking fake registration",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"REQUIRES" : [ "rules", "webform_rules" ],
"ON" : { "webform_rules_submit" : [] },
"IF" : [
  { "node_is_of_type" : {
      "node" : [ "node" ],
      "type" : { "value" : { "contactform" : "contactform" } }
    }
  },
  { "text_matches" : {
      "text" : [ "selected-webform:0" ],
      "match" : "plusgmail.ru",
      "operation" : "regex"
    }
  }
],
"DO" : [
  { "block_ip" : [] },
  { "mail" : {
      "to" : "admin@address.com",
      "subject" : "[site:name]: Blocking user [data:e_mail-value]",
      "message" : "E-Mail Adresse: [data:e_mail-value]",
      "language" : [ "site:current-user:language" ]
    }
   }
  ]
 }
}

I really appreciate any comments and help.


texts: Commerce order either stays as pending or grants double to customer

texts:
I have 2 rules to handle orders of credits on my site.

The first rule changes the order status to Completed if the order is no longer a cart.
The second rule grants credits to the order owner using a loop.

The problem is that the credits are granted twice.

In the user's orders page, the order appears twice with the same ID. But it only appears once in the admin orders page.
If I omit the first rule and change the order status manually it works fine. In this case, it is still using the same loop. Can anyone think why this might be? Here are the rules:

{ "rules_order_paid_in_full_order_state_to_completed" : {
    "LABEL" : "Order paid in full: Order state to Completed",
    "PLUGIN" : "reaction rule",
    "WEIGHT" : "1",
    "ACTIVE" : false,
    "OWNER" : "rules",
    "REQUIRES" : [ "commerce_cart", "commerce_order", "commerce_payment" ],
    "ON" : { "commerce_payment_order_paid_in_full" : [] },
    "IF" : [
      { "NOT commerce_order_is_cart" : { "commerce_order" : [ "commerce_order" ] } }
    ],
    "DO" : [
      { "commerce_order_update_status" : { "commerce_order" : [ "commerce_order" ], "order_status" : "completed" } }
    ]
  }
}

{ "rules_grant_credits" : {
    "LABEL" : "Grant Credits on Completion",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "TAGS" : [ "Checkout", "commerce", "credits" ],
    "REQUIRES" : [ "rules", "entity" ],
    "ON" : { "commerce_order_update" : [] },
    "IF" : [
      { "data_is" : { "data" : [ "commerce-order:state" ], "value" : "completed" } }
    ],
    "DO" : [
      { "LOOP" : {
          "USING" : { "list" : [ "commerce-order:commerce-line-items" ] },
          "ITEM" : { "line_item" : "Line Item" },
          "DO" : [
            { "component_rules_grant_credits_if_product_is_credits" : { "line_item" : [ "line_item" ] } }
          ]
        }
      }
    ]
  }
}


texts: Return from Controller is expected to be array, how to return an array that redirects?

texts:
I have a "redirect" query parameter in my URL.
I get this parameter and after doing some things I want to redirect.

But the content() method is expected to return an array, so returning Symfony's RedirectResponse is giving me a warning in PHPStorm.

What is the correct way to do it?

Thanks.


texts:
I am having my navigation links in my utility bar which is in a block named 'tray'; however, some users prefer to have the navigation links in the normal position and that is in a side panel inside a block named 'second sidebar'.

How can I make it so that the users can choose on their profile to either use the utility bar and navigate from there, or leave it as it is and have the links in the sidepanel.

Update: I mentioned panels, but it should have been blocks.