texts: How to add CCK fields to my own content type provided by my own module in D6?

texts:
I'm creating a module which provides a new node content type. I can extend the default node creation fields with my owns, but I would like to add some CCK fields too (like CCK ImageField) by default, NOT manually after enabling my module through the usual admin interface of Drupal's content type editor.

So for example here is my own form in my module that provides a new content type; this is what I would like to extend with a CCK ImageField (and later maybe add other CCK fields too):

/**
 * Implementation of hook_form()
 * @see my_test_module_for_content_types_node_info()
 */
function my_test_module_for_content_types_form($node){
    // Get metadata for this node type
    // (we use it for labeling title and body fields).
    // We defined this in seat_reservation_node_info()
    $type = node_get_types('type', $node);

    $form['title'] = array(
      '#type' => 'textfield',
      '#title' => check_plain($type->title_label),
      '#required' => TRUE,
      '#default_value' => $node->title,
      '#weight' => -5,
      '#maxlength' => 255,
    );

    $form['body_filter']['body'] = array(
      '#type' => 'textarea',
      '#title' => check_plain($type->body_label),
      '#required' => TRUE,
      '#default_value' => $node->body,
      '#weight' => 7,
    );

    $form['body_filter']['filter'] = filter_form($node->format);

    $form['test_blabla'] = array(
      '#type' => 'textfield',
      '#title' => t('This is my test field!!'),
      '#required' => TRUE,
      '#default_value' => isset($node->test_field) ? $node->test_field : '',
      '#weight' => 5,
      '#maxlength' => 255,
    );

    return $form;
}


texts: How to hide the inside page for anonymous user?

texts:
I have a view named Search User.

LINK: www.example.com/search-user

If any anonymous user directly open this link then this page shown.

How can I hide that View page for the anonymous user.


texts: How to do push data to datalayer after Ajax callback?

texts:
I have a view with many elements and use views load more -> view using views load.

Modules:

Views Load More.
dataLayer.

Is it possible send datalayer event after load elements with AJAX?

I am tracking with Tag manager (Google).


texts: How to access the block ID in hook_block_view_alter()?

texts:
How can I access the block ID in hook_block_view_alter()?

function mysite_block_view_alter(array &$build, \Drupal\Core\Block\BlockPluginInterface $block) {

  if ('my-block-id' == $block->maybe_there_is_some_method_that_returns_the_id()) {
    // Do something.
  }
}

Is there some way to inspect the $block variable?  I'm finding that calling var_dump or kint inside of hook_block_view_alter() has no effect.

Actually, I have not been able to confirm that the hook fires at all:

function mysite_block_view_alter(array &$build, \Drupal\Core\Block\BlockPluginInterface $block) {

  \Drupal::logger('mei')->warning('did it fire at all');
}

The above does not result in any messages in the log.


texts: Drupal 6: Having a menu where more than one Item is active

texts:
I'm trying to build a menu where a node can be a child of more than one item. That's not really an issue because Drupal 6 can handle it. However only one parent menu item will be active.

It's some sort of a portfolio where a client-node can be a child of photography and design and when the page of the node is opened the entry for photography and for design should be active.

Does anyone have an idea?


texts: What would be the Drupal way to have a preloader overlay divs untill they were finished loading?

texts:
I am trying to get a theme to have a pre-loader image run over each section of the theme until the corresponding div section is finished loading.

I am trying to refrain from a $(window).load(function()); if i can.

What would be the best approach?  Thanks in advance.


texts: How to show a table depending on a drop down selection?

texts:
Initially there is only drop down menu in the form, when a selection is made I want to display a table in the same form.

$form['blood_group'] = array(
    '#type' => 'select',
    '#title' => t('Blood Group'),
    '#options' => array(
        'a+' => 'a +ve',
        'b+' => 'b +ve',
        'ab+' => 'ab +ve',
        'o+' => 'o +ve',
        ),
    '#required' => TRUE,
);

suppose if the user selects a+ i have to show the table containing names of all the people with the same blood group.


texts: How to create a webform node with multi lingual language like french,spanish in drupal 6. so that when i hit the url it should display in particular language? webform localization is not supporting in drupal6. is there any other way around to do this. pls help?


texts: Drupal show breadcrumbs on certain nodes

texts:
I've been using the path by bread crumbs module (https://drupal.org/project/path_breadcrumbs), which allows me to create bread crumbs based on nodes. However the page the crumb is on, shows the title of the crumb.

Example: Home>>Node_Title

I want the Home crumb, but not the Node_Title (I'ts a long title as well).

This is what I want:

Node 36 URL= TitleExample

Breadcrumb example for Node 36: Home>> (no node URL)

Does this make sense?


texts:
I've got some migrations and they are basically doing their job. My problem is that errors in the data source end up in a WSOD in Migrate Tools UI, without any human readable error message (when I click on "List migration").

E.g. my source usually responds something like

{success: true, result: {my_dataset: {data1: 'Alice', data2: 'Bob'}}}

and in my YML I've got something like

source:
  plugin: url
  data_parser_plugin: json
  item_selector: /result/my_dataset
  fields:
    -
      name: data1
      label: 'Just an example'
      selector: data1

Today my source went down and returns a HTTP 500 with

{success: false, message: 'We are working on it, try later...'}

How can I force the Migrate Tools UI to display an error message and stay in the admin theme, instead of a WSOD?


texts: How do I add recaptcha to a custom form programatically?

texts:
I'm using the following contrib module: https://www.drupal.org/project/google_recaptcha

How do I add a recaptcha to my form programatically, since the form I'm using isn't listed under forms on the config page of the module?

The following doesn't seem to work:

$form['recaptcha'] = array(
  '#type' => 'recaptcha'
);


texts: How to prevent entering a time-slot that is already taken when using the Calendar module?

texts:
I have installed and enabled the Calendar module. I have noticed that this allows multiple events for the same time slots. It means if event 1 is on Aug 12th from 11-12, I can still enter the same time slot for event 2.

In this case, how can I apply a logic so it complains that if the time-slots already taken?


texts: Drupal 7 views - Contextual filter content: Nid content id from url

texts:
I am working on a portfolio website where there are a lot of projects on the website.

When you have a project node open I want a view next to it with all the thumbnails of other projects.

The problem is the following:
When I have the view setting set to Contextual filter content: Nid content id from url I want the reverse effect to happen. Because now it only shows the same node.

Please forgive my bad english, I hope you can help me!


texts: How to affect kernel request hostname when bootstrapping from custom PHP script

texts:
I'm bootstraping from a custom PHP script using:

$autoloader = require_once 'web/autoload.php';
$request = Request::create('/');
// $_SERVER['SERVER_NAME'] = 'whatever';
// $request->server->set('SERVER_NAME', 'whatever');
$this->kernel = DrupalKernel::createFromRequest($request, $autoloader, 'prod');
$this->kernel->boot();
$this->kernel->prepareLegacyRequest($request);

When rendering a URL from that bootstrapped Drupal, via $item->link->getUrlObject()->toString(), it has a localhost hostname:

http://localhost/sites/default/files/styles/large/public/images/pages/1.JPG?itok=gSuAsMq-

I want to change that to whatever and I've tried what is commented out in the initial block which doesn't work. I've confirmed that the $request->server->set(..., ...); does set the value though.

Any idea on how to solve this?


texts:
I am little stuck with creating a module for drupal.

I would like to show users a link: "Create", then to take them to a page where will be forms.

Can someone post little piece of code so i could see how to implement other...

Thank you!!!


texts: Views field for Billing cycle always returns empty

texts:
I've added the following field to Views

Commerce Order: Billing cycle (Billing cycle)

and unfortunately it always returns empty whereas other fields as Created,  Updated,    Status return their values normally.

In fact it is not Views field issue, because if I click on any order item and go to its page the Billing cycle is empty there too. I applied the patch on Disclose billing cycle information on order page to customers and I hope it didn't cause this issue.


texts: Prepopulate a field in a Reference Dialog Box

texts:
I have 2 content types named Incident and Migrant. Both of them have fields that reference each other. My question is how to prepopulate a field in a reference dialog box while the node is being edited?

How am I going to prepopulate Incident field with Incident 36 nid. When the popup/dialog loads? Assuming that Incident field is a Autocomplete Text Field?

Here's what I tried, I have tried Entity Reference Prepopulate but, I figured that that the Reference Dialog is displayed via iframe so getting the nid from the URL wont work.

I'm very new to drupal and still in the learning curve so if possible answer me in a detailed fashion.

Modules i used

Entityreference prepopulate
Reference Dialog


texts:
I'm using drupal_goto to redirect users on login.
Administrators and 'other' are redirected to the dashboard. All works fine but I want to redirect to the dashboard in an administrative overlay.
(Path = #overlay=nl/admin/dashboard)
Chrome and Firefox alter the # to %23 so I get a page not found error.

Can this be done?

Here is the function:

/**
 * Implements hook_user_login().
 */
function myModule_user_login(&$edit, $account) {
  $user_roles = array_intersect(array('other', 'administrator'), array_values($account->roles));
  if (!empty($user_roles)) {
    drupal_goto('admin/dashboard');
  } else {
    drupal_goto('');
  }
}


texts:
I want to redirect a specific user when he logs in.

There are 4 users.

Each one must go to a different url.

Under the rule I have

What do I need to put in for the conditions?


texts: Taxonomy exposed filter with parent hierarchy only

texts:
I have a taxonomy vocabulary with terms in hierarchical order. If I use an exposed filter, with level depth, all terms are listed, which are > 6,000. I want only the parent terms, which are only around 30.

I found here the following code (I adapted it to my case). It is an answered question, but obviously it does not apply efficiently to my case, because though it does what is suppose to do, it goes through every item and as a consequence is extremely slow (several seconds). Is there a better way that does not directly make a db_query to the taxonomy database tables or use a hook (PHP) ?

function mymodule_form_views_exposed_form_alter(&$form, &$form_state, $form_id) {
  if($form['#id'] == 'views-exposed-form-search-page-page'{
    foreach ($form['term_node_tid_depth']['#options'] as $term_key => $term) {   // Check if this isn't the 'ANY' option
      if($term_key !== 'All') {
        // Check if this is a child by looking for '-' as first char in string
        $term_value = reset($term->option);
        if($term_value[0] == "-") {
          unset($form['term_node_tid_depth']['#options'][$term_key]);
        }
      }
    }
  } // if
} // function


texts: Create a user friendly workflow to create banners

texts:
I'm looking for an easy way where my users can add banners on a page. There are many options here (View Slideshows, Rotating Banners,...) but what I want is a user to be able to do this as simple as possible.

The ideal scenario would be:
Create content - upload image - type a title and select the pages on which it should be displayed.

Basically, my (absolute n00b users) must be able to add a banner to any page available without any knowledge of views, panels,...

I've experimented with node references and templates, but no luck so far.

Is their anyone with the same situation and found out a great solution?


texts: Using Entity Print to generate several PDFs of a Webform submission

texts:
This may be too vague a question as I'm just starting to work through this. Would very much appreciate any pointers/experiences if people have done something similar.
Functionality I'm hoping for:
User completes a webform survey and upon completion they are able to download two PDFs that have differing data/results form specific sections of the webform.
A more concrete example, the webform first asks profile questions about age and job type, conditionally on that the second half of the form pulls in different questions (ie. if you answered being under 50, you get question set A, if over 50 get question set B). Once the user submits the form they could download two separate PDFs, one a summary of their profile, and the second a summary of their answers to the conditional question sets.
I've got webform and entity print running, and can see the 'view/print pdf' function added to webform submissions, and have been able to link to that PDF on the confirmation page. But I'm not sure about the best way to approach creating two separate PDFs. Views seems the best approach, but how would I link it all together? Is there another way? Like I said, apologies, this is probably too vague, just trying to avoid going down dead-end paths.
Thanks very much.


texts: Multiple sites routed to one codebase has the subdirectory name as prefix on the links

texts:
I am trying to redirect multiple drupal sites to same code base using following htaccess file

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?site.com$ [NC]
RewriteCond %{REQUEST_URI} !^/subdirectory/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ subdirectory/$1
RewriteCond %{HTTP_HOST} ^(www.)?ngeneric.com$ [NC]
RewriteRule ^(/)?$ subdirectory/index.php [L]

It workds but, now every URL on the site has its subdirectory infront like

  http://site.com/subdirectory/.....

How to fix this?

More Info: Domain is routed to public_html/a/ The drupal site in inside this a directory as public_html/a/b and I am trying to use multiple sites, so I am getting this problem.


texts: How to choose between classic SQL query and Drupal 8 technic?

texts:
I have a custom content entity (amap_distributions_inscriptions) linked to 2 entity_reference 'datedistributionid' (which is basically the date of distribution plus other fields) and 'amapienid' (which is mainly the people who can attend to the distribution).

I want to create a form allowing people to enroll to the distribution, i.e. choose a date among all possible and their role.

In the past (a module I wrote for Drupal 6), I had a db_query joining the three tables, sorting by date, name of the people, etc. I processed the result of the query with a while ($record = db_fetch_object($result)) to build a tabular form with all dates and already enrolled people and so on.

What would be the "Drupal 8" way to do that?

I started with a

$storage = \Drupal::entityManager()->getStorage('amap_distributions_inscriptions');
$ids = \Drupal::entityQuery('amap_distributions_inscriptions')
  ->execute();
$inscriptions = $storage->loadMultiple($ids);
foreach ($inscriptions as $id=>$inscription) {my code here}

but I'm struggling with retrieving 'date distribution' and 'amapien', then sorting the results before starting to build the form rows...

Any guidance?

Trying to use @ssibal's advice, I assume I should write something like

$database = \Drupal::database();
$result = $database
  ->select('amap_distributions_dates', ???)
  ->fields('ddate', 'iid', 'pid', 'irole', 'nom', 'prenom')
  ->condition('dnumber', 0, '>')
  ->execute()

My D6 query ('amap_distributions_dates', 'amap_distributions_inscriptions' and 'association_personnes' being the 3 tables):

$query = "
SELECT
    amap_distributions_dates.ddate,
    iid,
    amap_distributions_inscriptions.pid,
    irole,
    nom,
    prenom
FROM
    amap_distributions_dates
    LEFT JOIN amap_distributions_inscriptions ON amap_distributions_inscriptions.ddate = amap_distributions_dates.ddate
    LEFT JOIN association_personnes ON association_personnes.pid = amap_distributions_inscriptions.pid
WHERE
    dnumber > 0
ORDER BY
    amap_distributions_dates.ddate ASC,
    iid ASC,
    irole ASC,
    nom ASC,
    prenom ASC
";


texts: Is a session alone enough for non logged-in users to see some information?

texts:
In my project I have a content type called Person that is only viewable or editable by logged-in user. In this content type, I added some fields.

I want to give a person the ability to visit his profile. So I made a module called anonymous_profile with the following code.

function anonymous_profile_menu() {
    $items = array();
    $items['anonymous-profile-login'] = array(
        'title' => t('Login'),
        'page callback' => 'drupal_get_form',
        'page arguments' => array('anonymous_profile_login_form'),
        'access arguments' => array('access anonymous person login'),
        'type' => MENU_NORMAL_ITEM,
    );

    $items['anonymous-profile'] = array(
        'title' => t('Anonymous Visit'),
        'page callback' => 'anonymous_visit_page',
        'access arguments' => array('access anonymous person login'),
    );

    $items['anonymous-profile-logout'] = array(
        'title' => t(''),
        'page callback' => 'anonymous_logout',
        'access arguments' => array('access anonymous person login'),
    );
    return $items;
}

anonymous-profile-login creates a form where users insert information in order to log in on the anonymous-profile page. anonymous-profile-logout is the logout page.

function anonymous_profile_permission() {
    return array(
        'access anonymous person login' => array(
            'title' => t('access anonymous person login'),
            'description' => t('Anonymous person login form to view profile page.'),
        ),
    );
}

This is the form object that is returned to anonymous-profile-login.

function anonymous_profile_login_form() {
    $form['field_national_id'] = array(
        '#type' => 'textfield',
        '#title' => t('National ID'),
        '#size' => 10,
        '#maxlength' => 20,
        '#required' => TRUE,
        '#description' => t('Please insert your national id'),
    );

    $form['submit'] = array(
        '#type' => 'submit',
        '#value' => t('Login'),
    );

    return $form;
}

This is the form submission handler.

function anonymous_profile_login_form_submit($form, &$form_state) {
    $national_id = $form_state['values']['field_national_id'];

    $login_result = false;
    if ($national_id == '123456') { //this is for test.in real , inserted national id must be searched in database...

        $login_result = true;
    }

    if ($login_result) {
        drupal_set_message('Login is ok');
        $_SESSION['anonymous_logged_user'] = $national_id ;
        drupal_goto("anonymous-profile");
    } else {
        drupal_set_message('Invalid login information', 'error');
    }
}

This is the logout page.

function anonymous_logout() {
    if (isset($_SESSION['anonymous_logged_user']))
        unset($_SESSION['anonymous_logged_user']);
    drupal_goto('anonymous-profile-login');
}

In anonymous_visit_page(), first I check the session anonymous_logged_user; if it is OK, I show the information to the user.

function anonymous_visit_page() {
    if (isset($_SESSION['anonymous_logged_user'])) {
        if ($_SESSION['anonymous_logged_user'] > 0) {

            $national_id = $_SESSION['anonymous_logged_user'];
            // load information from database bases on $national_id and print rendered html output.

        }
    }
    //--------------------------
    //visitor is not logged via form
    drupal_set_message('You must loggin in order to see your profile', 'error');
    drupal_goto('anonymous-profile-login');

}

Is this solution safe?
Is a session alone enough for this method, or must I increase the code safety?
Is there any possibility the session is stolen, and users access information without log in via form?

I am using Drupal 7.


texts: How to configure drush with Acquia DevDesktop on Windows to access through proxy?

texts:
There are some answers to similar questions using WAMP, but now drush is not recommended under Windows (unless using DevDesktop, which I am). And this is seriously frustrating. I followed the instructions here and created a wgetrc file with the proxy addresses and use_proxy=on on d:\, then set up a wgetrc environment variable to point to d:\. Stopped and started DevDesktop to verify that the wgetrc variable is taken into account. But when i try to download a module (eg drush dl admin_toolbar), I get an error message:

  simple_xml_loadfile(): I/O warning : failed to load external entity Project.php:74 Failed to get available update data from https://updates.drupal.org/release-history/admin_toolbar/8.x

Following the comments below I tried again (twice). Once, with the env variable WGETRC set to d:\wgetrc, next with the file renamed to _wgetrc as suggested and the env variable set to d:. Neither worked, here is what seems to be the relevant wget output (obtained by redirecting the output to a file):

First attempt:

Wgetrc:
  d:\wgetrc (env)
  /etc/wgetrc (system)
Locale: /usr/share/locale
Compile: gcc -DHAVE_CONFIG_H -DSYSTEM_WGETRC="/etc/wgetrc"
  -DLOCALEDIR="/usr/share/locale" -I. -I/usr/src/wget/wget-1.12/src
  -I../lib -I/usr/src/wget/wget-1.12/lib -D__CYGWIN__ -DEILSEQ=138
  -O3 -fno-unit-at-a-time -s -march=i386 -mtune=i686
Link: gcc -O3 -fno-unit-at-a-time -s -march=i386 -mtune=i686
  -Wl,--enable-auto-import /usr/lib/libssl.dll.a
  /usr/lib/libcrypto.dll.a /usr/lib/libiconv.dll.a
  /usr/lib/libintl.dll.a /usr/lib/libiconv.dll.a -lregex ftp-opie.o
  openssl.o http-ntlm.o gen-md5.o ../lib/libgnu.a

Second attempt:

Wgetrc:
  d:\ (env)
  /etc/wgetrc (system)
Locale: /usr/share/locale
Compile: gcc -DHAVE_CONFIG_H -DSYSTEM_WGETRC="/etc/wgetrc"
  -DLOCALEDIR="/usr/share/locale" -I. -I/usr/src/wget/wget-1.12/src
  -I../lib -I/usr/src/wget/wget-1.12/lib -D__CYGWIN__ -DEILSEQ=138
  -O3 -fno-unit-at-a-time -s -march=i386 -mtune=i686

As far as I can see it is looking in /etc/wgetrc no matter what I do, which is not much use on Windows. In all cases I get this error still:

https://updates.drupal.org/release-history/file_entity/8.x [3.81 sec,16.55 MB]
Executing: wget --version
Executing: wget -q --timeout=30 -O "C:\\Users\\mknapp\\AppData\\Local\\Temp\\dow6C08.tmp" https://updates.drupal.org/release-history/file_entity/8.x
simplexml_load_file(): I/O warning : failed to load external entity    [warning]

I've even tried putting the wgetrc file in c:\windows\system32\drivers\etc but to no avail


texts: Enable field inside Manage Display from a .yml file

texts:
When I create a field field.field.node.custom.body.yml in my custom module with the following code:

langcode: en
status: true
dependencies:
  config:
    - field.storage.node.body
    - node.type.customblog
  module:
    - text
id: node.customblog.body
field_name: body
entity_type: node
bundle: customblog
label: Body
description: ''
required: false
translatable: true
default_value: {  }
default_value_callback: ''
settings:
  display_summary: true
field_type: text_with_summary

The Body field is created and added to the appropriate CT when installed, but is set as disabled in the manage display. This seems to be default behavior. I would like the field to be enabled as the module is installed through the use of .yml files, is this possible?


texts:
I need to show a custom feedback form when canceling an event.

I used a jQuery modal form for this purpose, but I want to use any Drupal 6 module, or functionality, to save the feedback for future purposes.

Is there any module I can use?


texts: Connect Content Type with Related Taxonomy Fields using Template

texts:
I have a Content Type displaying correctly using a template, pulling out the fields to appropriate locations.

I now want to pull in related information from two separate taxonomies. I have a term reference to each Taxonomy setup as a field in the Content Type.

I have the taxonomy fields mapped out in the template, but the output is empty. I believe it is because I need to define a relationship somehow.

My current direction is to create out a view using EVA and render it to the template (which is poor for performance), but I am struggling to figure out how to define the relationship to the node.

Please provide examples of how you would approach this problem.

For context, Content Type is a job listing. Taxonomy B is information about the respective company. Taxonomy C is information about the respective city the job is in. Both Taxonomies can be made into Content Types if that helps.


texts: Drupal Commerce have customer choose how many items to buy

texts:
I would like to give my customers an option of how many products to buy.
So I would like to have a page (or view) that gives the user the option to but 1, 3, or 6 items of my product each with a little more discount.
For example:
 1 for $3.50
 3 for $7.50
 6 for $10.00

And have those three options displayed next to each other.

Also, I would like to give the customer no other quantities. It is either 1, 3 or 6 items that they can buy.

Anyone knows how to do this?


texts: Reference parent token of a content-type X via content-type Z to generate URL alias?

texts:
I have three content types (X, Y, Z) and each have an Entity Reference field.

Content-type X has an Entity Reference field to a Taxonomy vocabulary with two terms, A and B. Term A has a child, 1.
Content-type Y has an Entity Reference field to X.
Content-type Z has an Entity Reference field to Y.

By using Pathauto and enabling Entity tokens, I'm able to generate some nice URLs for these content-types:

Content-type X
example/vocabulary-parent(if present)/vocabulary-term-child/content-type-x-year

Content-type Y
example/vocabulary-parent(if present)/vocabulary-term-child/content-type-x-year/content-type-y-name

But, I run into an issue when I'm trying to create a URL with content-type Z. The token for child 1's parent (Term A) is not present -- or at least I can't seem to find it. The Pathauto pattern below only generates the child's name:

example/[node:field-content-type-z:field-content-type-y:field-content-type-x]

However, the token to access child 1's parent is present when generating content-type Y:

example/[node:field-content-type-y:field-content-type-x:parent]

Is there a way to generate a URL alias that includes child 1's parent name for content-type Z?


texts: How can I migrate taxonomy data from an outdated site?

texts:
I have a site building with an old version of D8. The site can not run up and all I get is a backup sql file. So I'm creating a new D8 site with the latest version, trying to restore the data.  When I trying to restore the taxonomy data, I import the related tables from my backup sql file into the new db and fixed some "revision" fields. The imported tables are listed below:
taxonomy_index
taxonomy_term_data
taxonomy_term_field_data
taxonomy_term_hierarchy

But I still can not load any of these data from the admin ui. Is there anything else that I need  do? Or another way to restore taxonomy data?


texts: How do I migrate node entity references?

texts:
I would like to migrate node entity references from D7 to D8. In my D7 application, many nodes are related to other with the "entity reference" system. But related nodes could belong to many node types like "article", "page", "news", and so on.
I tried to use "entity_lookup" plugin, but this does not work (SQL error):
field_related_content:
    plugin: sub_process
    source: field_related_content
    process:
        target_id:
            plugin: entity_lookup
            no_stub: true
            entity_type: node
            bundle_key: type
            bundle:
              - presse
              - news
              - page
            value_key: nid

SQL Error is:
In Connection.php line 701:

  SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens: SELECT base_table.vid AS vid, base_table.nid AS nid
  FROM
  {node} base_table
  INNER JOIN {node_field_data} node_field_data ON node_field_data.nid = base_table.nid
  WHERE (node_field_data.nid = :db_condition_placeholder_0) AND (node_field_data.type = :db_condition_placeholder_1:db_condition_placeholder_2:db_condition_placeholder_3); Array
  (
      [:db_condition_placeholder_0] =>
      [:db_condition_placeholder_1] => presse
      [:db_condition_placeholder_2] => news
      [:db_condition_placeholder_3] => page
  )

Someone has an idea?
Many thanks!


texts: Folder permission errors on public:// after upgrade to 8.8.5

texts:
I'm new to this community, and asking for help because I'm stuck on this problem, and cannot go past. I've also tried asking on StackOverflow, but with no luck so far.

My current setup:

Drupal 8.8.5
CentOS Linux release 7.5.1804
PHP 7.2.19 and HTTPD - Apache/2.4.6
Run user/group: apache:apache

The /admin/reports/status#warning admin page reports that "the sites/default/files directory is not writable. You may need to set the correct folder in the configurations of the File system page or change the permissions of the current folder so that it is writable."

Obviously, this leads to a number of errors:

Drupal\Core\File\Exception\FileException: Failed to unlink file 'public://css/css_Y3zRgmC0P7yIXk_w_H9qyrPs3aMkKRv44SMfupbSCMc.css.gz'. in Drupal\Core\File\FileSystem->delete() (line 340 of/var/www/html/project/core/lib/Drupal/Core/File/FileSystem.php).

Warning: unlink(/var/www/html/project/sites/default/files/css/css_Y3zRgmC0P7yIXk_w_H9qyrPs3aMkKRv44SMfupbSCMc.css.gz): Permission denied in Drupal\Core\File\FileSystem->unlink() (line 124 of /var/www/html/synergie/core/lib/Drupal/Core/File/FileSystem.php)

The specified file 'temporary://fileuJjxaE' could not be moved to 'public://js/js_FKKJ_OhNvc7muQ1i_fQS6OJmZLsZnRvVhbbPaVlNwb8.js'.

Permissions for the file cannot be set for sites/default/files/translations

Now, I'm not a full expert on Drupal, but I've already tried doing all the possible basic things that these situations require on a linux system:

Setting all 777 to /var/www/html/project/sites/default and subdirectories
Changing owner of the directory aforementioned
Manually debugging lines 124 and 340 of lib/Drupal/Core/File/FileSystem.php
Sudoing on "apache" user with sudo -s /bin/bash apache and try to create/delete files from the command line (and it works)
Writing custom scripts that run under apache:apache, outside Drupal, to see if they can manipulate public://. (they work)

I think the problem is not in the filesystem itself, because whatever combination of permissions doesn't work, I believe this problem is connected to Drupal itself.

Fact is, if I write a custom script to write/read/move files from/to the /var/www/html/project/sites/default/files, it just works. It doesn't work "from within" Drupal.

As said before, I'm not a expert of all the "under the hoods" of Drupal like file settings, admin settings, drush, so I'm asking to you to try and issue this problem, because it's driving me crazy. Spent the last 10+ hours watching the command line and not understanding what's happening.

Kind regards,

Maurizio


texts:
In Drupal 7 (i18n) there is a possibility to select an existing node as a translation of another node.

In Drupal 8, is there also that possibility?


texts:
I am trying to generate a URL for an image style, generated from an image in my theme directory:

$image_uri = drupal_get_path('theme', 'mytheme') . '/images/banners/projects-banner.jpg';
$banner_file = file_build_uri($image_uri);
$banner_url = image_style_url('my_image_style', $banner_file);

The $banner_url looks to be correct, however when I browse to it directly, I get a general Drupal error.

http://www.mysite.local/sites/default/files/styles/my_image_style/public/sites/all/themes/mytheme/images/banners/projects-banner.jpg

I had tried to pass $image_uri into image_style_url, but understand this need a URI and not a path. Can someone please point me in the right direction.


texts: For a personal-use module, what would be good practice for database tables?

texts:
I've a set of tables that install with my module, but I worry about mixing them in with Drupal's tables.  I shouldn't simply create a separate database for my own tables, should I?

Is there a 'good' approach to this?


texts: View Field Display placing table label on top of the description

texts:
So I have this table created with display suit and table group.

How am I going to make it look like this?

The label is already set to be above, but that doesn't seem to work.

I'm not really good in CSS nor Drupal. Consider me a newbie and willing to learn.


texts:
Commerce Google Tag Manager module provides following rule actions:

Send "Add to Cart" event to google analytics via GTM
Send "Remove from Cart" event to google analytics via GTM
Send "Checkout" event to google analytics via GTM
Send "Purchase" event to google analytics via GTM

Created following 4 rules:

Send Add to Cart Details to GA via GTM
Event: After adding a product to the cart
Action: Send "Add to Cart" event to google analytics via GTM
Send Remove From Cart to GA via GTM (Not having any session in GTM to track these details)
Event: After removing a product from the cart
Action: Send "Remove from Cart" event to google analytics via GTM
Send Checkout Complete Details to GA via GTM
Event: Completing the checkout process
Action: Send "Purchase" event to google analytics via GTM
Send Checkout Process Details to GA via GTM
Event: Process a change to the checkout page (Enabled Commerce Rules Extra module for this event)
Action: Send "Checkout" event to google analytics via GTM

Using above 4 rules data is tracking properly under Ecommerce -> Shopping Analysis->Shopping Behavior Analysis to 'All Sessions', 'Sessions with Add to Cart', 'Sessions with Check-Out', 'Sessions with Transactions' but 'Sessions with Product Views' is empty. Please help.

How to track Sessions with Product Views data to Google Analytics via GTM in drupal 7?


texts: Edit panel not showing up (Gear -> Edit Panel -> NOTHING??)

texts: If I go to a custom panel and click the gear, then click edit panel, the link changes as if a popup appeared, but nothing else shows up. I cleared my cache on my browser, computer, on the website, and even tried it on my coworker's computer but it still doesn't work. I also tried it on Chrome, Firefox, and Safari and still no success.  Any thoughts?


texts: Running cron every minute on Pantheon with Elysia Cron

texts:
I am on pantheon now and I've never used a cloud host before so I'm used to being able to set cron on the server. This is totally new territory for me. I have some tasks that I need to run every minute and others only during off hours. To do this I have installed Elysia Cron. However, Pantheon does not seem to have the ability to set cron to run every minute so my settings within Elysia Cron are meaningless, but it's really unclear how I'm supposed to make up for that.

Pantheons Cron documentation is laughably vague. It only offered some loose direction without any explanation of really how it ought to be done. One suggestion is to use Pingdom, but there's no indication on how exactly that would work, so I don't want to sign up for a service before I really know how to use it to achieve my goal.

I assume that I just set my Elysia Cron task schedule and then have pingdom 'ping' every minute at the location of Elysia Crons cron file with the key appended like so 'http://site/cron.php?cron_key=XXX'

Am I thinking in the right direction here?

UPDATE

I spoke with pantheon support and they confirmed that this was correct.

If you don't already have a pingdom account and want to do this with a free service, freshping will target your cron url as much as once per minute.


texts: I wonder if it is possible to have different domains set for, for instance, per path basis, or view basis, or node id basis?


texts: How to print the Views title in page.tpl.php?

texts:
I could print the view with this code in page.tpl.php.

print $view->display['view_display_name']->display_options['title'];

How can I print the Views title ?


texts: How to get the unread message count using EntityFieldQuery

texts:
Using below query I am getting the count of all messages of a user. Now i need to filter them to unread messages only.

global $user;
$query = new EntityFieldQuery();
$count = $query->entityCondition('entity_type', 'message')
 ->propertyCondition('uid', $user->uid)
 ->count()
 ->execute();


texts: How to limit what is available for a role in Administration menu ?

texts:
I am using Drupal 7 and installed the Administration menu. It works fine and I am really happy with it but after creating a new role, and also creating a new user for that role, he seems to have the entire menu available even though permissions are restricted.

To clarify, I removed permissions to flush cache and administer blocks. When he clicks those links, it says access denied but he can still click the links. How do I keep those links he cannot click from appearing in the menu at all?


texts: Is Drupal 4.7 compatible with Mysql 5.1 and PHP 5.3

texts:
I am having some strange problems with Drupal 4.7.11 on my local machine. Before I get into it I should give you some context. I am running PHP 5.3.4 and MySQL 5.1.54.

If I try to run Drupal 4.7 without any DB info it comes up to a screen that asks me to put in the DB connect info. Once I do that I get a white screen in my browser and in terminal running cron.php I get a DB connect error.

Now as I was writing this I realized that PHP 5.3 is probably a problem here. But I might as well ask anyway.

So thoughts on compatibility?

UPDATE: I realized that my machine is running two different versions of PHP because I am on a Mac and it has 5.3. However, my Apache is running from Zend Desktop which is 5.2. So the site is setup in 5.2 right now.


texts: Views body field pop-up not loading and preview not working

texts: Recently we have moved our website from our own hosting to Pantheon. Since we've made the move the Views body field pop-up won't load anymore. Pop-ups for other field may or may not load. Also the Preview function in Views isn't working either. Because this may sound vague I've made a screencast display the problem. Also no errors are shown or created in the logs. I suspect it has something to do with AJAX.


texts:
I want to call my custom field_widget_form with the use of drupal_get_form()
Is it possible to do that?
simple requirement .. I want to build a form where user enter the field value and that value should be store with the node but only one field value instead of all 30 fields.

Now i have created the field with custom code so how can i call this function field_widget_form() in that or any other help full alternative.


texts:
I am building a simple checkout module and need some advice on how to structure this application.

So far the module consists of:

src\Entity\Transaction.php - Custom entity type for storing transactions.
src\Form\CartForm.php - Alters Cart (Cart data stored as a session via Drupal::service). On submit, user redirects src\Controller\PaymentController.
src\Controller\PaymentController.php:

Cart data is pulled from the Drupal::service.
Cart data (prices, items, etc) is configured the PayPal API.
A transaction entity type is created and:

stores serialized cart data inside the transaction entity as a map field,
stores data from the PayPal API,
transaction is saved.

After the transaction is created, the user is redirected to PayPal.
Upon successful/unsuccessful payment, data is passed from the PayPal website to the src\Controller\PaymentController.php again and transaction entity is updated.

So far it seems pretty logical however, I feel this could be improved structurally.

Currently, a lot is happening in the PaymentController (too much code in one file). Is there a component that Symfony or Drupal 8 offers that would split some of this code?

Any other advice on design and structure would be great as well. I don't anticipate using Drupal Commerce. My organization sells a few services and Drupal Commerce seems like it would be overkill.


texts: How to filter taxonomy term in views from URL

texts:
I am working on a travel website, and I made taxonomy with depth continent/country/city. I also have taxonomy locations restaurants, museums, nightlife... I have content types destinations and locations. I made a view from location content (all restaurants)

I would like to have locations filtered from destination taxonomy term in URL (e.g. destination/europe/france/paris to sort only restaurants from Paris, but destination/europe/france to list all restaurants from France).

Can anybody help?


texts: Migrate module only imports first line of CSV file

texts:
I have a Migrate module class that works with CSV files and when I go through with the import it only goes through the first line of the CSV and then completes with a success message.  That one line is imported correctly and the data is in place, but I'm wondering why it continues to stop at the first line.

When I run the import again it does not import anything and completes with success message again, mostly likely because the first line is already imported.

Any ideas?

class UserMigration extends MyMigration {
  public function __construct($arguments) {
    parent::__construct($arguments);

    $this->description = t('Import Users');
    $columns = array(
      0 => array('username', 'Username'),
      2 => array('email', 'Email'),
    );

    $this->source = new MigrateSourceCSV(drupal_get_path('module', 'my_module') . '/Users.csv', $columns);
    $this->destination = new MigrateDestinationUser();
    $this->addFieldMapping('name', 'username');
    $this->addFieldMapping('mail', 'email');
    $this->addFieldMapping('roles')
         ->defaultValue(DRUPAL_AUTHENTICATED_RID);
    $source_key = array(
      'username' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      )
    );
    $this->map = new MigrateSQLMap($this->machineName, $source_key, MigrateDestinationUser::getKeySchema());

  }
}


texts: How can I pull slideshow filenames from the database using jQuery?

texts:
I've have a jQuery plugin I'm using in my Drupal 7 site to make a fullpage background slider. I load it from a javascript file. How can I get the image names from Drupal's database instead of having to manually edit the list of images in the javascript file?

Here's the .js I load in my theme:

(function($) {
  Drupal.behaviors.BackgroundSlider = {
    attach: function(context, settings){
      $.backstretch([
            "/sites/default/files/styles/background_transition/public/ba5933c356c60f895785da952f8ad3e4_0.jpeg?itok=PjRiZj-V"
          , "/sites/default/files/styles/background_transition/public/8bad4c95b3776bed84222abe4c5288ba.jpeg?itok=cKq-2Dgj"
          , "/sites/default/files/styles/background_transition/public/78cefce14e9d9a613b0bc1950da662c6.jpeg?itok=4pAyvgsM"
          , "/sites/default/files/styles/background_transition/public/00336b1506db0487ea33af734abd3b16.jpeg?itok=QcS5dV2K"
      ], {duration: 3000, fade: 750});
    }
  };
})(jQuery);


texts: I'm new to Drupal. What I'd like to do is create a form on a new page, having full control over the css/html of the form, and post the form to PHP for processing. The PHP should do some custom things to the form data, dump some stuff to the DB, return some stuff from the DB, and either redirect to a new page or return an error. No need to go into details about the PHP/DB stuff - just need to figure out how to go about creating a new page, and where to post the form to for processing. Should be able to figure everything else out from there!


texts: What extensions are used in a module, and what do they mean?

texts:
I suppose there's a drupal page somewhere that explains this, but I can't find it.

When creating a module, you can have files that end with .module, .info, .inc, etc...

What are all the file extensions that are recognized and what do they do?


texts: how to comment individual image in popup form drupal 7?

texts: I have created view to display images and when I click on the image it gets displayed in pop-up form. I want to allow user to comment on image in pop-up form only so i have displayed comment form with php code. But its not working properly. It displaying preview button instead of comment. And when I click on preview it redirects to the image node page which should not be happened. I want it to work properly please help me suggesting solution. Hope image below will help you to understand what actually I have done.


texts: Pass values to twig file from #theme options

texts:
I need to create a select field in a config form and pass values to it along with custom #theme options.
Its easy to pass header & row values. But after selecting a value from select box, I need to load another dropdown, Below is my reference code:
addslider.php
 public function buildForm(array $form, FormStateInterface $form_state) {
 $vid = 'my_categories';
 $terms =\Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadTree($vid);

 foreach ($terms as $term) {
   $custom_categories[$term->tid] = str_repeat('-', $term->depth) . $term->name;
 }
  $form['block']['sliders'] = array(
  '#type' => 'fieldset',
  '#title' => $this->t('My Sliders'),
  '#collapsible' => TRUE,
  '#collapsed' => TRUE,
  '#theme'  => 'my_custom_slider_table',
);

foreach ($block['sliders'] as $key => $slider) {

$form['block']['sliders'][$key]['tid'] = array(
  '#type'          => 'select',
  '#title'         => t('Categories'),
  '#options'       => $custom_categories,
  '#required'      => TRUE,
  '#default_value' => !empty($slider['tid']) ? $slider['tid'] : NULL,
);
}

hook_theme() in module file:
function mycustom_theme() {
  return [
    'my_custom_slider_table' => [
    //'variables' => [
    //'header' => $header,
    //'rows' => $example_rows,
    //'attributes' => array('id' => $table_id),
    //],
    'variables' => [
    'slider ' => [],
    ],
  ],
];

}

my-custom-slider-table.html.twig file:

      {{ 'Taxonomy select' }}
      {{ 'Reference Node' }}
      {{ 'Options' }}

 {{ slider }}	Test Sponsors	Edit/Delete

I need to get the output of $custom_categories variable in twig file, for the first td in {{ slider }} . Can you please help, new to Drupal8.


texts: Alter Ubercart Billing/Delivery Panes with User Profile Info

texts:
I'm trying to set a user's profile fields into the checkout process. A user must change these data only in own profile. The uc_addresses module is unsuitable for my needs. In the order form I need to hide these fields.

Right now I'm using uc_cart_checkout_form_alter to do this:

function my_module_form_uc_cart_checkout_form_alter(&$form, $form_state, $form_id) {
        // load user data
        global $user;

        $user_fields =user_load($user->uid);

        $first_name   = $user_fields->field_name['und']['0']['value'];

        // add data to order form
        $form['panes']['delivery']['delivery_first_name'][LANGUAGE_NONE][0]['value']['#default_value'] = $first_name;
}

But default value isn't there. Where did I go wrong? How can I fill out an order form (Delivery & Billing information) programmatically in Ubercart?


texts: Views url paths not using proper url on localhost

texts:
When running site on localhost and using field rewrite I construct a link like this for example

Set as default

I get a path that is not proper. Something like this

http://localhost/1/addresses/shipping/default/284

and it is missing a site part in url and should be like

http://localhost/MY-SITE/1/addresses/shipping/default/284

I have set a $base_url in settings.php but doesnt help. When I put site online this works fine, but what should I do for localhost?


texts: Within a node, how can I reference the value of a field of a node associated to the current user through a node-reference?

texts:
I'm creating a customer extranet for my client. The users are my client's customers. Within the body of a page node, I need to display the ID of the customer (company) to which the current user belongs.

Here's how I've set it up so far:

Drupal 7
I have a Customer content type that has a field called customer_id (among other things).
I have added a node-reference field to the User fields that references one Customer node. (In other words, each user is associated with one Customer.)

So in his profile, the current user has a node-reference value pointing to a Customer node, and I need to retrieve and display (in a page node or block) the value of one field (customer_id) in the Customer node being referenced in the current user's profile.

I've been going through several Drupal books and whatever module documentation I can find, and I've been experimenting with various views using the the Views module, but I'm still pretty stymied. Can somebody point me in the direction of a good way to implement this?

Thank you for your help!

Chris


texts: How do I clear the cache for a single node?

texts:
In my module, I can call cache_clear_all() (D7) or drupal_flush_all_caches() (D8), and this would clear the cache for all the nodes.

Is there a way to clear the cache for a single node?

What I need to do is setting up a module that, when it selects a story on a list, it changes the value of a node field. Right now, I change the field value by updating the database table containing that value, but I need to clear the cache for the value to be updated across the site.

Is there's a better way to update a node than directly changing the database table?


texts: Format for webform submission node tokens?

texts:
I have a field on my webform node which is an entity reference to a taxonomy term. I'm printing it in the webform using the token [webform_submission:node:field_sports], which prints the field output, but formatted as a link to the term page, whereas what I want is plain text. For webform submission values, there is the :raw format, but trying to use this with the node field token results in the error "Computed value/markup is using the following invalid tokens: [webform_submission:node:field_sports:raw]."

This token does not seem to respect the display settings on the content type, either; removing the link there does nothing for the display on the webform.


texts: Drupal 8 block cached, but the expensive call still runs

texts:
So I created a custom block like this:

  public function build() {
    $output = [
      '#cache' => [
        'keys' => ['bix_salary_jobs'],
        'contexts' => ['url.path'],
        'tags' => ['bix_salary_jobs'],
        'max-age' => 60 * 60 * 24 * 7
      ]
    ];

    // expensive call comes here.
    $data = expensive_all();
    $output['data'] = $data;
    return $output;

From the browser, I can see this block is cached, because the same content has shown there. If cache is not enabled, i.e, if #cache is removed, the content will be different.

Now my question is since this block has been rendered using the cache, why this expensive call expensive_all(); is still running every time this page refreshes? I can see it runs because I put a var_dump("call runs") inside expensive_all();. This message always shows when page refreshes.

My assumption is since this block has been cached, those expensive call inside this block could be avoided, and that's the purpose of cache. If this expensive call still runs with cache, then this block cache becomes useless.


texts: How to restrict what content types can be added to a Book?

texts: In activating the book module, I've noticed that all other content types on a Drupal 7 site have an option to add their nodes to a book. It would be ideal to restrict only the book nodes to go into a book. Does anyone know how to prevent other content types from being allowed to join the book party?


texts: How to get a list of fields that are used in entities?

texts:
I want to retrieve all fields that entities are using (including locked fields).

How can I get a list of fields that are used in entities?

Like we get in admin/reports/fields.


texts: How to add the Group Role as body class in the page template

texts:
I like to add the Group Role of the currently logged in user to the body class of the page twig template.
So this is not the same as the user roles the user account has.
Currently using Drupal 9.0.3. with the Group module.
I understand that for user roles, it is
{% set roles = user.getroles(TRUE) %}
{{ dump(roles) }}
But what is it for Group Roles?


texts: Passing a node refernce id to a form via hook_form_alter()

texts:
using Drupal 7

I'm trying to write a module that alters the node add form of a certain content type. This content type has a node reference field that normally displays as a drop-down. I'm also attaching this node add form to the bottom of the content it references, what I'm trying to do is populate the node reference field by using hook_form_alter() and passing in arg(1) of the page (passing it the nid of node I want it to reference).

I'm trying to figure out exactly how to do this. I've tried to do a drupal_set_message('<pre>'. print_r($form, TRUE) .'</pre>'); on the form to see how exactly to pass in the node reference, but it just prints out a huge nested array, and I'm unable to really figure out how I would format that as input I know it's going to look something like this;

function mymodule_form_alter(&$form, &$form_state, $form_id){
    if($form_id == "my_node_form")
    {
        $form['title']['required'] = FALSE;
        $form['node_reference_field_name']['nid'] = arg(1);
    }

}

but I'm still really confused on the actual syntax


texts:
This is a follow up to Ubercart alter product price when product added to cart.

I have an attribute called "Billing Term". It has options: 6 months, 12 months and 24 months. If 6 months is selected, 0% discount must be applied. 6 months, 5% discount must be applied. and 24 months, 10% discount must be applied.

I set up the attributes to make no change to the price, because I can't find a way to make attributes adjust a price by percentage.

The best solution to my problem would be to find a way to specify attribute discounts in %. But I couldn't find a way to do that. If you know of a way, please do tell, as that is for sure better than my other options below.

So, with all attribute adjustments to be 0, I figured I could something similar to what was done here (but this post is for Drupal 7). So I tried this:

function comply_advantage_uc_cart_alter(&$items)
{
  print '<pre>'; print_r($items); die(); <--- this makes apache run out of memory
  print '<pre>'; print_r(arrray_key($items)); die(); <--- this prints out "2", and then "3" and then "5" etc.
  $items[45]->price = 29393; <--- this doesnt adjust the price

}

I was hoping to do something like this:

$items[5]->price = $items[5]->price * 0.95; // to apply 5% discount

How can I accomplish this?

I found out that $items[5] type is CartItem.


texts:
I have a "Filtered HTML" text field and have the convert line breaks to
 &
 tags option turned on in the configuration but when I'm adding content to a "Filtered HTML" field and use Shift + Enter to create a newline within the same paragraph Drupal seems to be adding in two
 tags rather than one, which I'd expect.

For an example the text

"I'm having
a great day"

gets turned into

"I'm having

a great day"

Is there any way to alter this behaviour to add just one
 tag instead of two?


texts: Don't allow users to create nodes until they have at least one comment

texts: I'm trying to create a community website using drupal where users can create accounts, login and create nodes but i don't want them to create a node until they have at least one comment on a node. I heard rules will be able to accomplish this but I don't know hw to set it to disallow users from creating a node until they have a content


texts:
I am using the Colorbox 7.x-2.8 to display contents. The colorbox is opened when an image is clicked. Inside, the description of the image is shown.  It renders/shows the whole content of the page but not the title itself.

The content title is also not showing in manage display, but it is on the manage fields. What other options can I do for this one?


texts: InnoDB not locking a SELECT statement using db_query()

texts:
From Any way to select without causing locking in MySQL? I found a way to implement a select query in a InnoDB table without locking.

The example code given there is the following.

SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED ;
SELECT * FROM TABLE_NAME ;
COMMIT

If I want to implement a similar statement using db_query(), can I do so by issuing three consecutive calls like the following code?

db_query("SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED")
db_query("SELECT * FROM TABLE_NAME")
db_query("COMMIT")

db_query() doesn't support multi-line statements, on Drupal 6.


texts: How to resolve the undefined property error message in the local module?

texts:
I am not a programmer so this is a little out of my league.

When I submit a question using the answers module, I receive the following error:

Notice: Undefined property: stdClass::$field_answer_count in
locale_field_node_form_submit() (line 410 of /home/******/public_html/modules/locale
/locale.module).

I do not know how to apply patches, such as a patch as suggested in https://www.drupal.org/node/1062072.

Any suggestions about how to resolve this error?


texts: How can I automatically visually number each webform component? e.g. 1) ... 2) ... 3)

texts:
I am building a webform and would like to number each question (webform component). What is the automated way to do this (rather than number the component label text)?

Webform 3 (but may move to Webform 4 later).

I've searched a bit for this, but get results about phone number fields :/

Thanks for your time.

Update

I have clarified the question to state that I want to visually number the components, the numbers themselves would not be related to the component id, rather, they would be for the benefit of the user. It would be used to number the questions e.g.:

Question
Question

etc.


texts: How do you install Drush 7 for Drupal 8? Installed composer and still doesnt work.

texts:
I'm trying to install drush 7 for drupal 8, but im hitting a snag. I installed composer and now i downloaded drush 7 and unzipped it to /opt/drush7

I get the follow error when running drush even after i installed composer:

$ ./drush

Error in argument 1, char 2: option not found r
./drush: line 124: [: too many arguments
Unable to load autoload.php. Drush now requires Composer in order to install its dependencies and autoload classes. Please see README.md

I then run this from the read me file:

$ composer install
X-Powered-By: PHP/5.5.17
Content-type: text/html

Warning: Composer should be invoked via the CLI version of PHP, not the cgi-fcgi SAPI
Composer could not find a composer.json file in /usr/local/bin
To initialize a project, please create a composer.json file as described in the http://getcomposer.org/ "Getting Started" section


texts: Why is it possible to write any string in the hash salt

texts:
I have researched a bit, but I couldn't find a precise answer to why it's possible to write any string in $settings['hash_salt'].

For me it doesn't make sense that the site chashes if no hash salt has been set and if I then go to settings.php and write,

$settings['hash_salt'] = 'x';

the site works just fine.

Why does the site work just because hash salt have any value?


texts:
How to let user upload multiple pics for avatar approval in Drupal 7.

1) I used the avatar approval module, but I want to upload multiple images for different user??

2) Different user can login from own profile and upload our images.


texts:
Here's my intention...
I have one view to output my Downloads (Downloads is set up a content type). As a field in the content type for Downloads, I have Product. The user can choose a product for which this download applies. For example, a product brochure for product A would then have Product A as it's product field.

I wouldn't want the content editor (my client) to be able to edit and control the views, I fear it'll blow her mind. So I want to create a single view, and have this view (as a block) display on every Product page. I only want the downloads for the relevant products being displayed, not every single product.

The Downloads view is set up, but at the moment it just lists every download for every product. Is there a way to try and match [field_download_product] replacement pattern with the page's title?

Could you suggest an alternative set-up to achieve this?


texts: Migration to localhost causes 404 errors

texts:
I'm trying to copy my site on my computer.

I've successfully downloaded and setup all the things. My site localhost URL is http://localhost/rich/ and when I run this URL, it opens my site homepage perfectly; after this, any clickable link gives me a 404 error page.

When I run this URL http://localhost/rich/user on my localhost, it gives me the following error:

  Not Found

  The requested URL /index.php was not found on this server.

Can anyone tell me what is wrong? What should I do it to fix it?


texts: How can I get image url in a views field, D8

texts: The D8 Views image formatter has only one option: Image. I would like to get the url that's in the markup, not the markup, in my views field output. Do I need to make a custom formatter, or is there contrib code to provide this option? I can't find anything on d.o that looks useful. Also, I don't see any way to rewrite the text using tokens to get the image url.


texts: How to make a specific region use a specific template?

texts:
I'm currently working on Drupal 7 project in a Zen sub-theme. Each of my region uses "region.tpl.php" as HTML/PHP template. I just created a new region called "foo". This region needs a different HTML/PHP than the other regions.

How do I make Drupal use my custom template "region--foo.tpl.php" instead of the default "region.tpl.php"?


texts: I have downloaded the Commerce Kickstart distro. In the product page there is a quantity field which you can use to enter your custom value; I want to display the total cost of current product in AJAX. Is it possible?


texts: How can I use config-set to "unset" the value of a variable?

texts:
I am trying to use config-set to "unset" a variable.  In this case, I have a media image field that has required crop types on it, which is breaking my behat tests, so I want to use drush to temporarily disable the requirement during the behat tests.

I tried something like this:

drush -y config-set core.entity_form_display.media.image.default content.field_media_image.settings.crop_types_required ''

But this breaks the config.  What's the correct way to "unset" a config value?


texts:
I have a menu in Drupal 7 with 2 main links like home and about us, but I have 3 sub menu in about us like

About us

About Us 1
About Us 2

I need to show these 2 submenu in a block and show active when about1 same for about2.


texts: Built all blocks, menu, taxonomies, view etc in Drupal CMS on localhost machine, but I need to export everything to the live server. Is it possible to use features or just export sql?


texts: add Global PHP code field to Views on condition

texts:
I want to add PHP field to View based on condition that certain logic field in content item is checked. How can I check that it is checked in PHP code?

More concisely: how can I check if some product's field is checked in Views?

The View is just showing list of contents


texts:
I've a content type article, where user can create new terms to a vocabulary through free-tagging for example content, color and so on . When the user creates a new content, he can add new terms to the categories. Now I'd like to provide the new created terms also to be available in my forum vocabulary, so user can discuss about this terms in the forum.
I've assigned the vocabulary to my article and to my forum. But that alone does not work the way, I'd like to.
In the meanwhile I'm using the Taxonomy Manager for just copying the terms from the 'article' vocabulary to the 'forum' vocabulary.
But that's not the best solution for me, cause I've to manually do this for every added term.
It would be great, if this could happened 'on the fly', some kind of automatically.
Can anybody please help me to get this working?
Please also let me know, if the problem is not getting clear to you.
Thanx for your suggestions.


texts: How to create a chart system with Date ranges like Google Analytics?

texts:
I want to create a chart system for my website, for the apparel trend forecasting company. To do so, I want to add trends of sales based on today, yesterday, this week, this month, and year trend.

I have created the chart, but can't find any module to solve my purpose. I tried the Date Facets module, but I don't know why I cannot get it to work, even though I have installed the Facet API too.

Is there any similar module to make this work?

Some more details about what I'm trying to do:

suppose it's a chart about shirt trends.
about these types of shirts: sleeveless, half sleeve, or full sleeve.
filtered by Today, Yesterday, This week, This month, this year.


texts: How to sort taxonomy facets alphabetically in views?

texts:
I have created an expose filter using facet indexed field. Added an sort expose filter to it. There is a taxonomy term field. User need to sort that field ASC/DESC alphabetically order.

But it sort depends on taxonomy ID.


texts: The Drupal way of adding HTML syntax within hook_redirect_alter

texts:
I'm trying to setup client-side redirects instead of server-side redirects.  Since Varnish is being used for caching, I would like that to remain; so the request should not get to Drupal, Varnish should handle the redirect.  Ultimately, using session cookies, I'm trying to have the value for source/referrer path available at the landing page (because redirects clear the original referrer headers).

In Drupal 7, within a custom module, I'm using hook_redirect_alter() to stop the redirect process, then print out javascript to the page to do the redirect.  My question is, what is the Drupal way of adding the below print statement to the page within this hook?

/**
 * Implements hook_redirect_alter().
 */
function mymodule_redirect_alter($redirect) {
  print('

      redirect . '">Javascript is disabled. Click here to continue

  ');

  // This kills sever-side redirect
  exit();
}


texts: How to record unique hits in node counter stats?

texts:
Is there a way to only count the unique views in the core node counter stats?

I was using the Statistics Advanced module for Drupal 6 but there is no Drupal 7 solution. The quote below is from the Statistics Advanced module and what I want exactly is that.

  Only track 'unique' views of content: If you keep viewing a node over
  and over again, the "x reads" counter won't increase each time. This
  is applied on a per-user basis as well as a per session id for
  anonymous users.

The Node View Count module doesn't effect the core statistics, it creates a new table for itself. So this is not an option for me.

What I'm looking for is a solution that effects the CORE statistics, nothing else.


texts: Is there a way to conditionally change the state of a collapsible field group in admin, ie without changing a template or module file?

texts:
I want to move the Metatags, keywords and edit summary into collapsible field groups at the top of the node edit page, but keep it open the first time the node is created, but collapsed in subsequent edits.

Can some CSS or Javascript be used to accomplish that? I don't want to do it in the file system code, whether are module or a template file.. I'd prefer something using the Admin even if it means applying some PHP there. If a module like the Context module can be used to test whether it is a newly created record and change some settings that will be fine.


texts: How to install and enable a default and admin theme in a Drupal 8 install profile with just YML (without using hook_install() or a .profile file)?

texts:
I want to avoid using hook_install() so I can install from configuration.

I'd like my install profile to use seven for the admin theme, and my custom theme rutherford for the default/main frontend theme.

The annotated *.info.yml example on Drupal.org suggests that putting the following will install my themes:

# List any themes that should be installed as part of the profile installation.
# Note that this will not set any theme as the default theme.
themes:
  - rutherford
  - seven

My understanding of CMI is that I can then create a file called www/profiles/rocket/config/optional/system.theme.yml and put this in it to enable my themes:

admin: seven
default: rutherford

However none of this seems to work? My themes are found, but not installed or enabled:

Edit:

I've just noticed that the themes are set as default and admin, they're just not installed:


texts:
How can I export the "Enable for OG Menus" content type option status in a feature?

I have successfully exported several different OG content types into their own feature. All my settings have exported, except for the "Enable for OG Menus" option. I have a couple types where that option is enabled, and I have og_menu as a dependency. But when I enable the content type feature on a new Drupal instance, that option remains in it's default unchecked state.

I have Drupal 7.39, Features 7.x-2.6, OG Menu 7.x-3.0, and Strongarm 7.x-2.x-dev installed. As well as their dependencies.

Is there a Strongarm variable I'm missing? I don't see any in the list that look like they come from OG Menu.

I have Googled, didn't find anything relevant with the search terms I tried.

I searched the issue queues of Features, OG Menu, and Strongarm to no avail.

Any suggestions?


texts: Webform2PDF doesn't display arabic characters

texts:
I'm using webform2pdf with TCPDF library to generate pdf of submissions, I have some arabic words in the submissions, the generetaed pdf doesn't display them.
Is there any config to do to solve this issue?


texts:
I have a View that creates a tabbed block with different content types shown in the different tabs. I now want to add a Webform as another tab.

Normally I would add the webform in under the Filter settings and the Webform:Body as the field.

The problem in this case is that I am also using a Contextual Filter to filter the content types depending on the page the user is on. As the webform doesn't have a Content:X field like the other types do, the filter just filters out the webform.

I've got as far as creating an attachment for the view, and created a Contextual Filter based on the Webform: Node with the default value set to 'Raw data from URL' and I think the next step is to create a custom PHP Code validator to match the argument from the URL with a specific webform NID... but I can't seem to find a decent example of what this should look like.

I'm thinking of something simple like:

$ct1_forms = array(100, 110, 120);
$ct2_forms = array(200, 210, 220);
return ($argument == 'content_type_1' and in_array(NID, ct1_forms)
    or ($argument == 'content_type_2' and in_array(NID, ct2_forms)

The main thing I don't understand is how to reference the Webform: Node field in the validator.

Am I barking up the wrong tree, is there another better way of doing this,
or can someone show me how to create the validator correctly?


texts: Drush make on Windows 7: Where does my ssh key go?

texts:
I'm on windows 7 using (I think) the current version of drush, installed using the msi install file.

I have to download a proprietary drupal distro from a proprietary server using a drush make file containing ssh directives.

I've registered my ssh key on the server side already.

I cannot figure out where to put my ssh key on my client side. I've been scouring google and the drupal forums and gotten no certainty about what to do.

I saw one item about setting an option in a file called drushrc.php. But I don't see one in my current install. Neither do I know how to construct one or where to put it.

Any advise would be much appreciated.

Thanks for reading.


texts:
How can I go around having a single route that would internally be forwarded to a controller depending on some internal logic. I've looked into dynamic routes but it doesn't help since the route is shared, not dynamically created (ie "my/page")

In symfony I could do this $this->forward('AppBundle:Something:fancy',$params) but I've been unable to do this in Drupal 8.

I also looked into middleware since it looked promising but I couldn't figure out a way of doing it either.


texts: Views Contextual Filters and URL Aliases

texts:
Forgive me if this is a repost, but I have spent days trying to figure this out and everything I have found on drupal.stackexchange and elsewhere have been no help and I am struggling to understand the what views is doing exactly...  Here's my problem:

I have a website that has 2 different content types:  category and static content.

Within category content type, three pieces of content:  little, medium, and big.

In the static content content type, I have a autocomplete entity reference field called "Category" that points back to the category content type.   Next, I have three more pieces of content:

article1, article 2, article3.

Each has a unique title, no path alias set and the category reference field set to "little."

(Just using the "little" category for this question)

So, my goal here is to have the user enter the URL

www.example.com/category/article-title

and have a view generate the output (I don't want direct access to the node as I want to control all the content formatting).

Now, I can do a "simple" filter on the Content: Category (field_category) for "little" and the view will display all articles where that condition in met.  My problem comes in with the contextual filter and a URL alias.

No matter what I do in contextual filters, if I use a path alias, it will not work.  However, if I use a node number (in this case, 2 for "little"), it will work properly.  For instance:

www.example.com/little

will show no results.  But,

www.example.com/2

works (2 is the node number for "little").  In this case, the view generates output with content from node 4 (an article with the title "Little Brown Jug").  This is what it is supposed to do.

I have used both page view and block view, I have created relationships linking the content referenced and the content referencing the category field.
(I am sure this works as I can create related article pages with these relationships)

Whether I do this on the preview panel or directly on the URL, the results are the same. the term "little" generates no output, yet "2" does.

Any help here understanding this would be greatly appreciated.

I have added some screen shots


texts: Node references - show view link, rather than create link, if already exists

texts:
I've searched all over to try and find a solution for this - hoping I've just been searching for the wrong stuff :)

Sounds easy, and I know it has to be, just have to find a way to do it within D7.

So, building a little calendar event manager. I have a custom content type for calendar events. Using Node References to tie an 'event application' (also a content type) to those events.  So users can come and sign up for an event.  We have an application approval process, which complicates this whole matter.

Nevertheless, it works great right now.  They view the calendar event node, and they can click on a signup link (put there by Node References).  But if they've already signed up, I'd like to just show them a link to view their current application, or maybe even a link to edit it and resubmit.  Something like that.   People are signing up for an event multiple times because they keep seeing the sign up link lol.

Any ideas?  Thanks in advance!


texts: How to limit db_update() to update first n rows

texts:
I want to update first n rows using db_update(). Is it possible?

I know we can use db_query(). something like

UPDATE <table_name> SET <field_name> = <value> LIMIT <num_rows>

I want to know whether this is possible using db_update()


texts: Hello i Am Using Drupal 7 and created  a slideshow using views and views slideshow so in slideshow when a user is clicking the image url is opening you can also check my slideshow at Windowhelpdesk.com When Anyone Clicks on image a url is opening i want to remove that url plz anyone help me to do this


texts: How to use entity field as div background image in Views Slideshow?

texts:
I have a "background image" field for a particular entity type. I want to be able to upload an image there, and have that image be displayed as a background image in a div created by a View. An example use case would be a Views slideshow where that background image would be the background image of the slide being viewed, and the entity title and any other chosen fields would be laid on top of that.

One thought I had was to rewrite the output of one of the slideshow fields but I'm not sure how I can rewrite the image into a "background image" position.

Is this possible? Any ideas on how to accomplish this?

Thanks!


texts:
I have a Views Page that displays content from articles matching a particular criteria.  That views page works as expected.

I also have a views block that is supposed to pull related content from the article (think taxonomy, but I am using content types instead).  I have placed this block on all pages (no exclusions) on the right sidebar (Garland).

My content URL paths are set up as such:

example.com/section/page-name

My views page is set up as:

example.com/section

When I access the article directly via .com/section/page-name, the block shows up properly with all of the correct relevant links.  This means I have configured my relationships and context filters correctly.

When I hit my views page and render the content there, the content gets rendered, but the block never shows up. (Just for grins and giggles, I put a test block with some garbage and it shows up every time; views page and article)

I am assuming it is due to passing a filter or something in the URL, but I am just assuming and even if I was right, I have no idea how to pass that info to the block so that it gets rendered.

A point in the right direction here would be greatly appreciated!


texts: How do I render nodes, now that node_view() has been deprecated?

texts:
In Drupal 7 I frequently use node_view() for rendering nodes (using view modes) in blocks or pages as follows:

$nids = array(123,456,789);
$nodes = node_load_multiple($nids);
foreach ($nodes as $node) {
  $node_view = node_view($node, 'teaser');
  $output .= drupal_render($node_view);
}
$build['nodes']['#markup'] = $output;
return $build;

node_view()/entity_view() has been deprecated and replaced by a view builder as explained in change record Entities are now rendered by a view builder . The information is not detailed enough for me to be able to figure out how to achieve the same result.

How can you render nodes in Drupal 8 so that the output can be used in the render array of a block or page?


texts: limit view result to only commented nodes

texts:
I created a view that gets the logged in user posts, But I need to alter that view a little bit to only show the posts that has a comment by a different user "not the OP".

Do I have to create a template and add PHP to it? or this can be done with views?


texts: How do I modify the HTML of my subtheme?

texts:
I created a bootstrap subtheme ouf of CDN. Modifying the CSS works, but how do I do it with the HTML? Where do I put new HTML elements? For example: I'd like to add some elements to my footer, make it background color black and have it the width of the screen (it's not by default in Bootstrap)

This is my subtheme folder:


texts:
I've installed and set up the deploy module; I've followed instruction on Installation docs of deploy module for D7 and double checked it.

When I try to deploy node content, and run the cron, everything work great, the cron successfully ran, i also get "published message".

And there is nothing error. But, when i check my production site, the content that i've tried to deployed is not there. I've read http://drupal.org/node/1600862. Also i've installed latest dev entity_dependency module. And the content still not being deployed. Can anyone suggest?


texts:
I got an error after trying to update two modules:

  Fatal error: Call to undefined function context_get() in
  sites/all/modules/context/context_ui/context_ui.module on line 422

Also:

An AJAX HTTP error occurred. HTTP Result Code: 200 Debugging information follows. Path: http://redneckrampage.ee/authorize.php?batch=1&render=overlay&id=78&op=do StatusText: OK ResponseText: Fatal error: Call to undefined function context_get() in sites/all/modules/context/context_ui/context_ui.module on line 422

Any ideas on how to fix this without deleting/renaming the module folder on the server?

Drupal version 7.22


texts:
When i try to access paragraph type page i get following error.

Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException: The "paragraphs_type" entity type did not specify a access handler

I am using Drupal 8.6.13. How can i resolve it?


texts:
This problem starts with the subtheme. I am using drupal 7 with a subtheme based on omega 3.1.

For some reason node title and admin tabs are displaying only on the home page and two basic pages, while they do not appear on the rest of the website(articles, basic pages, custom type content).

I tried goggling and trying out different solutions but none of them were successful.

So I thought I could create a view block that would display only a node title. in the view I used contextual filters 'content: Nid', display 1 item, fields 'content: title'. By default auto preview does not display anything, when you insert a node number or a page name it displays it's title which means that the view works fine(as example when I enter '1' it displays 'About me' title).

After that I insert the block on a page by going blocks > configure for the block view > selecting the region in the sub theme I am using and in Show block on specific pages selecting 'Only the listed pages' and typing '1' as an example.

When I click save block and going to about me page I still do not see the title then check by inspect the page there is no html for the block view found.

To check weather the problem is not in the omega, I switch to bartik and select to display the block for bartik theme too, but still cannot see it on the page. The answer is probably something really simple.


texts: How to add a taxonomy term value as a class?

texts:
I am trying to target a specific div with CSS. But for that, I need a unique class in order to target a specific taxonomy term. I look at this question, but that doesn't work as it will target all taxonomy terms.

I have created a vocabulary called 'Titles' which has the following terms in it:

Which will display the following in my browser:

Note that I am not using a view to display these titles. Instead, I used a preprocess function:

function MYTHEME_preprocess_node(&$variables) {
  $variables['authortitle'] = \Drupal::entityTypeManager()->getViewBuilder('user')->view($variables['node']->getOwner(), 'nodetitle');
}

How can I add "Writer" as a class to the <a> tag?


texts: PHPUnit calling external function as object

texts:
I'm doing a unit testing with my CVRClient file using the code below.

//CvrapiTest.php

<?php

namespace Drupal\cvr\test\Cvrapi;

use PHPUnit_Framework_TestCase;
use cvr\src\Cvrapi\CVRClient;

class CvrapiTest extends PHPUnit_Framework_TestCase {

public function testSearchOnlyVAT()
    {
        $result = \Cvrapi\CVRClient::request('29910251', 'dk', 'vat', 'Unit Testing');

        $this->assertTrue(property_exists($result, 'vat'));
        $this->assertTrue((int)$result->vat === 29910251);
    }

I have a CVRClient class under cvr/src/Cvrapi folder that queries data from an api.

I know that phpunit command is working fine but I'm getting the error below.

  Fatal error: Class 'cvr\src\Cvrapi\CVRClient' not found in
  /Applications/MAMP/htdocs/query/modules/custom/cvr/test/Cvrapi/CvrapiTest.php
  on line 17

NOTE: It's the \Cvrapi\CVRClient:: that causes the error. If I remove this line, I need to have a code to assign values to $result.


texts:
I have been working on this code and I am having some errors, and I was wondering if anybody can find errors in this code...  I have posted my error below it...

function background_audio_form($form, &$form_state) {

$form['background_audio_file']['file'] = array(
  '#type' => 'managed_file',
  '#title' => t('File'),
  '#description' => t('Allowed extensions: mp3'),
  '#upload_location' => 'public://MP3/',
  '#default_value' => variable_get('background_audio_file'),
  '#upload_validators' => array(
    'file_validate_extensions' => array('gif png jpg jpeg mp3'),
  ),
);

$form['submit'] = array(
  '#type' => 'submit',
  '#value' => t('Save Changes'),
);

  return $form;
}

function background_audio_form_submit($form, $form_state) {

 // The file is automatically uploaded and saved in the default
 // validation process so you just need to load the file object at this point,
 // mark that you want to keep it, and save it again.
 // The file ID is contained in the $form_state['values'] array
 $file = file_load($form_state['values']['background_audio_file']);
 $file->status = FILE_STATUS_PERMANENT;
 file_save($file);

 $fid = $form_state['values']['background_audio_file'];

 $fileid = file_load($fid);

 variable_set('background_audio_upload_path', $fileid->uri);

}

Notice: Undefined index: background_audio_file in background_audio_form_submit() (line 107 of /Users/jtharpe/Overflow_Dev/sites/all/modules/background_audio/background_audio.module).
Warning: array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 178 of /Users/jtharpe/Overflow_Dev/includes/entity.inc).
Notice: Undefined property: stdClass::$uri in file_save() (line 573 of /Users/jtharpe/Overflow_Dev/includes/file.inc).
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '' for key 'uri': INSERT INTO {file_managed} (filesize, status, timestamp) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2); Array ( [:db_insert_placeholder_0] => 0 [:db_insert_placeholder_1] => 1 [:db_insert_placeholder_2] => 1329961119 ) in drupal_write_record() (line 6975 of /Users/jtharpe/Overflow_Dev/includes/common.inc).


texts: Caching problem. Site only works with cache off

texts:
I have this drupal 7 site.
I wanted to clone it in order to try some new stuff in it, without working on my localhost. So I did it, following these steps:

Cloned the database:

mysqldump -h localhost -u XX -p XXX > backup.sql
mysql -h localhost -u newXX -p newXX < backup.sql

And then cloned the files and changed their perms:

rsync -avHl /home/XX/public_html/* /home/newXX/public_html
chown -R newXX. /home/newXX/public_html/*

After that I've updated and changed the settings file (to use in the cloned files the new database credentials), and created a new .htmlaccess file.

All went well and good. The new site was just like the older site, and both sites were running ok.

A few days have passed since then.

But after that the old site have all WSOD inside every page, except the frontpage.

It was a cache problem, that didn't solved clearing all cache tables, but adding this into my settings file:

$conf = array(
'cache' => '0',
'preprocess_css' => '0',
'preprocess_js' => '0',
'block_cache' => '0',
'page_compression' => '0',
);

The thing is that I can't have my site without caching, and even after successfully logging in and manually unchecked all cache items under admin/config/development/performance, I get the WSOD if I try and remove the $conf array I've manually set at the settings.php file.

Note: I have memcached installed on my server, and this is what I've added in my settings.php file:

$conf['cache_backends'][] = 'sites/all/modules/memcache/memcache.inc';
$conf['cache_default_class'] = 'MemCacheDrupal';
$conf['memcache_key_prefix'] = 'memcache_liga';
$conf['cache_class_cache_form'] = 'DrupalDatabaseCache';

Please note that I've uninstalled memcache module on the cloned site, and deleted that configuration inside the settings file of the cloned site.

Why is all this happening? And what I may do about this?

Update: I forgot to mention that I've added to my index.php right after the opening php tag, this:

error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);

And when the error appears (WSOD), the page is still completely blank!


texts:
I am currently trying to inject a value and file into a user field called "field_user_pdf".

I am adding values to the following tables which is successful initally:

field_data_field_user_pdf
field_revision_field_user_pdf
file_managed
file_usage

The user is then able to see the file on their user profile. The user does not have permission to add/edit the file themselves, only an admin does, using the field_permissions module.

However if they edit and save their profile, all record of the file is deleted from the database.

This behaviour does NOT occur if the file was added to the user by an admin in the CMS, it only occurs when the file is inserted in MySQL by circumventing Drupal.

I have come to the above tables by both scrutinizing MySQL Insert logs as well as MySQL Database Dump diffs before and after.

Is there a table or column I am overlooking? Is there any where I can view the SQL Schema for inserting SQL for file fields?


texts: Drupal 8 ajax form load error, context.querySelectorAll is not a function

texts:
I have created a custom module with ajax call, which are sending render form data that I receive in my ajax prototype in a js file like below.

Drupal.AjaxCommands.prototype.loadCommentFormCommand = function (ajax, response, status) {
    if ($('#comment-form-wrapper').length === 0) {
        $('.wall-posts').prepend(response.html);
          Drupal.attachBehaviors(response.html);
        }
      };

But it's showing me

context.querySelectorAll is not a function

Error.
Does anyone face similar error or have some solutions for this?


texts: Prevent rule from triggering on Entity Reference Fields

texts:
I am trying to add a rule that does something when the user views my content type "contacts", so I used the "Content is viewed of type" event to trigger the rule.

Contacts can also be added to other nodes via the Entity Reference Field. Eg. for the content type "events" you can add the contact in charge of it.

Problem is now that this rule also triggers for content type "events", cause of the "contacts" reference.

How can I prevent that?


texts: How limit access to a paragraph type by role, like it is for content types?

texts:
The permissions page at /admin/people/permissions provides very fine grain control over which actions people can do with specific content types. How can I  add all paragraph types under this permission system? We have a paragraph type that is reserved only for special cases, and we don't want anyone but a certain custom editor role creating/editing them.

I've searched for a few contrib modules, but many are not updated (or just plain abandoned) with little documentation.


texts:
I am using the pathauto module to create url aliases for all user account url, so:

/user/[uid] will become /u/[user:account-name]-[user:uid]

which means:

/user/36 will become /u/john-smith-36

In my custom module, I have created a route to fire a controller when /u/john-smith-36/settoken?token=123456 url is accessed.

The controller will:

Fetch the account of the current logged in user.
Update the text field field_user_push_token with the query parameter value:
123456
Save the account of the current logged in user.
Redirect the user to the page: /thank-you

I am finding a difficulty on how to use parameters in route for the user account url !

save_push_token.routing

save_push_token.SavePushToken:
  path: '/{user}/settoken'
  defaults:
    _controller: '\Drupal\save_push_token\Controller\SavePushTokenController::SavePushToken'
  requirements:
    _permission: 'access content'

SavePushTokenController.php

<?php

namespace Drupal\save_push_token\Controller;

use Symfony\Component\HttpFoundation;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Session\AccountInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\RedirectResponse;

class SavePushTokenController extends ControllerBase {

  /**
   * Display the markup.
   *
   * @return array
   */
  public function SavePushToken(AccountInterface $user, Request $request) {

// Get token value from url.
    $request = Request::createFromGlobals();
    $userpushtoken = $request->query->get('token');

// Load the (current logged user) account.
// No need to load the user account because of {user}
    // $user = \Drupal\user\Entity\User::load(\Drupal::currentUser()->id());

// Set the (token).
    $user->set('field_user_push_token', $userpushtoken);

// Save the (current logged user) account.
    $user->save();

// Redirect to "/thank-you" page.
    return new RedirectResponse('/thank-you');

  }
}

But simply the controller is not fired when I access for example /u/john-smith-36/settoken?token=123456 url is accessed.

any help on how to properly use parameters in routes ?


texts: form textfield name -value changed and does not validate any more

texts:
i have a checkout-page (drupal commerce) form with an address section generated by the module addressfield.
currently all text-inputfields have this markup-structure:

<input class="last-name" id="edit-last-name" name="customer_profile_billing[commerce_customer_address][und][0][last_name]">

class + id + name

in this config they validate.

if i change the value of the name attribute the form doesnt validate anymore, the form says:

  field XY is required

the form-validator obviously doesnt recognise my inputs.

question: how can i get the validation process to work with a modified name attribute?


texts: How can I get nested paragraphs out of Views JSON API?

texts:
I have a content type with embedded Paragraphs, and I'm trying to get those paragraphs into a JSON response, via a Views endpoint, along with the rest of the node. For example:

Product (content type)

Name (field)
Price (field)
Details (Paragraphs)

Description (WYSIWYG field)
Features (WYSIWYG field)

A dozen other random paragraphs (Paragraphs)

Getting the name and price fields out of JSON is easy. I've also learned that I'm able to get ALL the paragraphs concatenated into one giant string by using the "multiple rows" option in Views, but the problem is that each Product can have a dozen or more such paragraphs, most of which are useless for this API endpoint. Doing it that way results in one gigantic string that often fails parsing because of unpredictably embedded unicode (newer emoji, etc.) that aren't encoded correctly, no matter how I set the options.
I don't really care about most of those paragraphs. I just want to get the "Details" paragraphs and its fields in the response, but I can't seem to find a way to limit it that way. Adding "Details" as a relationship results in duplicate entries per product, I think because the WYSIWYG field is used in other paragraph types too. Most of the duplicates are blank. Making the "Details" relationship required then erroneously filters out all the products with no details, which is not what I want either.
Sorry, I've spent hours researching this, and maybe I'm just not using the right search terms...?
All I really want is one product per JSON entry, with a nested Details paragraph in the product, but not all the other extra paragraphs. Am I missing something obvious or is there really no easy way to filter by paragraph type in a View?
Thank you!


texts:
I am new to drupal and I have a task to create a custom admin theme. I read a lot of tutorial to how to create a theme in drupal and I am familiarize with that. But never see how to create a new admin theme. I also wanted to customize the default <input type ="text"....> fields with custom css.
Thank you in advance.. :)


texts: Taxonomy Menus - How to set up menu that goes to a view filtered by two terms?

texts:
I'd like to create a menu that looks like this:

Brand1
 - ProductsType1
 - ProductsType2
Brand2
 - ProductsType1
 - ProductsType3

When I click on a brand, I'd like to go the a list view of all products from that brand. When I click on a Product Type under a brand, I'd like to go to a view filtered to only products from that brand and of that type. However, the type is not defined by a Product Variation Type, they are all one Variation Type. I've created a vocab for types instead. (hooray for not finding a way to have one importer import to multiple product types...)

So, How do I create such a menu? It seems I'll need to link to a view filtered by two taxonomy terms. Is this somehow possible or is there another way around this problem?