texts: Add another button removes the default values from my fields on node form

texts:
I have a node form on which two fields are displaying.
One is a list of radio buttons which is required field.

I am getting a value from url using arg(3) and setting the default value of that field

$form['field_test'][LANGUAGE_NONE]['#default_value'] = arg(3);

I have a link field which is a multi valued field. It means this field as add another button.

When I click on this add another button and then submit the form, I see an error of Test field is required, and that default value of test field gone.

Without clicking the add another button everything works fine.

How can I set a default value of the test field in this case?

Code:

if (!$form['nid']['#value']) {
  if (arg(3)) {
    // Select the default value.
    $tg = arg(3);
    $form['field_test'][LANGUAGE_NONE]['#default_value'] = $tg;
  }
}

  // Make the field readonly.
  $form['field_test'][LANGUAGE_NONE]['#attributes']['disabled'] = 'disabled';


texts:
Since we launched we have added many new job roles and wish to set all new wiki pages so everyone can access. At present we are having to manually tick each role.

Is this possible?


texts: Naming Structure for Create Node Page template?

texts:
I need to create a custom template for:
/node/add/node

It's currently using:
page--node.tpl.php

What's the file naming convention for this?


texts: Can I set Commerce to accept floats for quantity rather than just integers?

texts:
I have a specific requirement for a certain product type in Commerce to accept the line-item quantity as a float rather than an integer. Is this possible?

For example 5.34 rather than 5.

The context

Product Type 'Tile' is sold in sqm (squared meters)
User chooses required quality in sqm when they add to cart
Drupal works out the minimum amount of tiles required for the chosen sqm value
The sqm value is then adjusted based on number of whole tiles required
Therefore sale price may be 5.12 sqm, if 5 sqm is required (because that is the specific sqm for X whole tiles.


texts: How to check config setting in custom service class with dependency injection?

texts:
In a custom Service class, I need to check a config setting.
I'm able to do this using \Drupal::config(static::SETTINGS) as documented here: https://www.drupal.org/docs/drupal-apis/configuration-api/working-with-configuration-forms
but Coder complains:

WARNING | \Drupal calls should be avoided in classes, use dependency injection instead

What service should I inject here?
I only need to see the immutable config value, I don't think I need a ConfigFactory.
More info:
When I try to inject the ConfigFactoryInterface, using the pattern I have followed for many other services, I get this error:

Error: Call to undefined method Drupal\my_custom_module\Api\DataPartner::config() in Drupal\my_custom_module\Api\DataPartner->hasDebugPermission()

The code in the hasDebugPermission() method looks like this:
  /**
   * Private function to control whether displaying debug info is permitted.
   *
   * @return bool
   *   TRUE if debugging is permitted for current user in current environment.
   */
  private function hasDebugPermission() {
    $config = $this->config(static::SETTINGS);
    $result = DATA_PARTNER_FORMS_DEBUG
      && $config->get('display_debugging_info')
      && $this->account->hasPermission('debug forms');
    return $result;
  }

And I have declared static::SETTINGS like this:
  /**
   * Config settings.
   *
   * @var string
   */
  private const SETTINGS = 'my_custom_module.settings';

The call to $this->account->hasPermission() works fine after injecting \Drupal\Core\Session\AccountInterface, but the call to $this->config('my_custom_module.settings')->get('display_debugging_info') does not work after injecting \Drupal\Core\Config\ConfigFactoryInterface.


texts:
Just on certain pages, I'm led instead to /core/install.php...

This has happened to me a great number of times now, in certain twig templates.  But, I can't imagine why.  Has anyone else had this happen?  What causes it?  It just doesn't work in some templates.  I'm only asking this because I have never seen anyone ask anything like it, and it has happened to a coworker as well.


texts:
When making my ticket-system I want managers to be able to reply to tickets when viewing the ticket. On the page to view any ticket I load my form. Because I want it to be a bit more fancier than just the default 'element under element' style I render each item by item manually.

<?php print drupal_render($form['open']); ?>

Now the problem is, my form doens't work. Clicking on my rendered submit doesn't perform any action.

My guess is that rendering each item manually doesn't include the 'form container'. How should I include is? Or is my style of working completely wrong?


texts: Can multiple revisions of a node (entity) have different languages?

texts:
For example, we have a published English node, and a user creates a new draft and set the language (from the node form) to German and creates a new revision. This way the latest revision of the node is in a different language. This result is couple of issue that I am trying to understand:

Is this allowed?
Can users create multiple drafts in different languages?

When I tried to do that on vanilla drupal 8 I found a few bugs. One issue that it would just throw fatal error when trying it with Article content type because it has synchronized fields that triggers some validations which throw the error. This has been reported.
But if you try this with basic page type, a draft in a different language is created. If you delete the draft the entire node is deleted. I would love to know how the language selector on node forms is supposed to work with revisions?


texts: Is it possible to run drush cron over a single module, something similar to "drush cron my_module"?


texts: How to split Webform in multi menus/tabs?

texts:
Is it possible to split my webform into several menus/tab?
Note: aim is not to obtain a multi step webform but a webform with several sections reachable easily by selecting a tab.


texts: Differences in adding classes to nodes and paragraphs

texts:
I'm trying to add some classes to a certain content type.
In mytheme_preprocess_node_contentype() I'm able to use $variables['attributes']->addClass('myclass')
However, in mytheme_preprocess_paragraphs__my_paragraph() using $variables['attributes']->addClass('myclass') throws an error as $variables['attributes'] is an array.

Error: Call to a member function addClass() on array in ...

Why are these two different?
Is okay to use addClass() in the node instance and just use $variables['attributes']['class'][] = 'myclass' in the paragraph instance?


texts:
I have a page where I set to show a 'Two column stacked layout'. So I assigned a block of links on the left region. On the right region, I will use Context to show the respective custom block based on the parameter passed from the link that user click.

But in Context, only the template's region are displayed but not those listed in the Display Suite. So how do I show hide the blocks in that "additional" region?


texts: I have researched a little bit and I haven't found a sound solution to downloading all attached files from all content types across an entire site in an single action. I have found a couple modules like Backup & Migrate, or its plugin Backup & Migrate Files that perform similar functions, but nothing to effect that I need. I am trying to archive all attached files for a schools site. The site is drupal7.


texts:
Just to start with I am trying to do this in code (installation profile), not in Drupal itself.
In my installation profile I create three text formats. Thanks to the drush make file tinymce is also automaticly installed. Now wysiwyg gives you the option to assign the editor to a text format. See image below how the option looks in Drupal.

Now I am wondering how I could change the 'No editor' to 'TinyMCE' in my installtion profile. After changing the option in drupal itself then the database changes to: (see image below)

What is the right way to do this and how can I change these module settings?


texts: Can taxonomy tags/terms be more than one word?

texts:
I've created a view that filters content based on the tags I associate with each page. It works great when my tags are single words.

In this case, posts containing any one of the above tags appear on my page.

However, I want to create and select tags for posts that contain multiple words (e.g. movie titles) such as Eternal Sunshine of the Spotless Mind, Garden State, The Aviator.

Currently, I apply tags via checkboxes (in case that's relevant), not using the autocomplete.

When I do this, the views filter only displays content containing the FIRST tag. For example, Only content using the Eternal Sunshine of the Spotless Mind tag is displayed, but content containing the other two tags is absent.

Any idea why this might be? Are my tags just too long? If so, how can I get around this? The following are the contextual filter settings.


texts:
Normally with Drupal 8 I can use dependency injection like this:

<?php

class ExampleController extends ControllerBase {

  private $http_client;

  public function __construct(HttpClient $http_client) {
    $this->http_client = $http_client;
  }

  public function create(ContainerInterface $container) {
    $http_client = $container->get('http_client');
  }

  public function getResource() {
     $response = $this->http_client->get('http://biebertunes.com?q=selena');
     return $response->getBody();
  }

}

I can then use the $http_client property's methods.

Now in my testing class I'm already extending the UnitTestCase class, so I don't have access to the create method for dependency injection.

<?php

class ExampleTest extends UnitTestCase {
  public function testGetResource() {
    $mock = $this->getMock('\Drupal\Example\ExampleController');
  }
}

Now when I run my unit tests it complains that I don't have the $http_client parameter. So how can I inject $http_client into the unit test without the create method?


texts: I can't filter the child view based on a value from the parent view

texts:
I have read many of the questions asked on this site, but none of them suited my problem. What is the need to make a Users view that shows below its created contents.
I have a website with 3 roles. Each role has the permission to create a content type. Users of the "Truckers" role can create nodes whose type is Trucks. The Username value is automatically added to a field, in order to identify which truck driver that truck belongs to. That field is an entity reference.
I need to create a view that shows users of the Truckers role and the trucks which belong to them. I created 2 views. One of them, based on the Trucks content type, lists the trucks, and among other fields, shows the Username of the truck driver who created it; the other one, based on Users, lists the users who have the Truckers role.
Using Views field view, I added the Trucks view as a field inside the Truckers view. However, I didn't find any combination of contextual filters, relationships, etc. that gives the desired result.
In the second image, you can see that the Trucks view is shown below each user of the Truckers role, but it shows all trucks, not just those created by the trucker.

I am not a programmer. How could I achieve the result I need? Is there a contextual filter, relationship, that I need to set? They have many options and I do not understand all of them correctly and in depth.
I am using Drupal 8.9.13 and Views field view 8.x-1.0-beta3.


texts: Sorting a view basing on the value of a boolean field

texts:
I have a content type X. A view is used to display this content type (X), as a table. The content type has a field called "Preferred" which contains boolean values. I need to sort the table so that the "Preferred:true" items display at the top of the table.

How can I achieve it?


texts:
I want to share my video site on Facebook.
Facebook detect only thumbnail of video.
I see France24.com add og:video on the source of site and show direct video on facebook.
I use auto_opengraph but this module can't generate og:video
How  can i do?


texts:
I have to create a module that return a list of my language, only the list without template,and I have to call this url via curl

I create something like this ( inside my module )

function my_module_menu() {
  $items['my_module'] = array( //URL
    'page callback' => 'get_all_languages',
    'access arguments' => array(''),
  );
  return $items;
}

/**
 * @return string
 */
function get_all_languages() {
    $out = array();
    $result = language_list('enabled');
    foreach ($result as $key => $value) {
      foreach ($value as $k => $v) {
        $out[$v->language] = $v->name;
      }
    }

    $p = json_encode($out);
    print $p;
    drupal_exit();
}

I tried also

  drupal_add_http_header('Content-Type', 'application/json');
  $p = drupal_json_encode($out);

But this url is not Json infact if call this url by Curl, I can see all the template.
I want to have the result like using this module, or can i Create a view that use my module result?

I have another problem when use curl, my content is

  You are not authorized to access this page.


texts: Is it possible to alphabetize a sorted view?

texts:
Drupal 7.18 w/ Views 7.x-3.8 user here.

I have a view set up that consists of rows of objects, which have names and 'yes/no' properties. By default, it is sorted alphabetically by object name. I want to allow the user to be able to sort through the view using the various properties, but to then have those sorted results be alphabetized for them post-hoc. Currently, when the user sorts through the view using property X (with either 'yes' or 'no' content), the objects seem to be retrieved based on their location in the database table, or some other factor. Either way, they are in no way alphabetical which means that this view of 500+ results is impractical to sort in this fashion.

So, is it possible to set up a sort mechanism where the results are (1) sorted by property into their respective 'yes'/'no' groups (or any other groups with identical content for that matter) and then (2) alphabetized?

To demonstrate what I mean, I currently have something like this:

NAME    PROPERTYX
Alpha   yes
Beta    no
Delta   yes
Epsilon no
Gamma   yes

Which when sorted using PROPERTYX (let's say descending), might return something like:

NAME    PROPERTYX
Delta   yes
Alpha   yes
Gamma   yes
Epsilon no
Beta    no

(As I said, I suppose this random order is based on the object's actual location in the database table.)

When the desired output would be:

NAME    PROPERTYX
Alpha   yes
Delta   yes
Gamma   yes
Beta    no
Epsilon no

Can this be accomplished somehow?


texts: Weird Character output Field Collection data with Views Data Export (CSV)

texts:
I am using Field Collections on a content type, in Drupal 7. I am exporting this data as a Views Data Export with these collections. I can get everything to print out, however, I get a weird special character and I cannot seem to get rid of it. Below is the output. I don't like the way it looks but getting rid of the special character is paramount.

Name of Conference:Â Conference TypeTitle of Abstract:Â Testing each field and its meritsAuthors:Â Tim Snip, Fish Head, Testing Page, Water CupCity:Â AtlantaState:Â GACountry:Â U.S.A.Date:Â June, 2018

I have been clicking every check box and testing everything I can but not luck. Is there a way to get rid of this? or find out why it is even showing up?


texts: Rule running after node update shows previous content

texts:
Using Drupal 7.15. I wrote a rule containing custom PHP code that POSTs the node ID to an external system. That system accesses the Drupal REST server, retrieves the specified node, and copies its content.

Problem: It gets the version that existed before the current save command. The action specifically says that it is run "After updating existing content" so I can't understand why I consistently get the previous version.

0 ms Reacting on event After updating existing content.
15.618 ms Evaluating conditions of rule TEST rule on save content. [edit]
15.652 ms AND evaluated to TRUE.
    0 ms Rule TEST rule on save content fires.
    0.265 ms Evaluating the action entity_save. [edit]
    1.155 ms Saved node of type node.
        0 ms Reacting on event After updating existing content.
        0.393 ms Not evaluating reaction rule TEST rule on save content to prevent recursion. [edit]
        0.412 ms Finished reacting on event After updating existing content.
    26.716 ms Evaluating the action php_eval. [edit]
    1944.527 ms Rule TEST rule on save content has fired.
1960.253 ms Finished reacting on event After updating existing content.

Similar problem, but for user instead of node: Rules - After updating / saving user not working

Discussion on drupal.org: http://drupal.org/node/430274  I have tried the fixes suggested in replies #13, 14 on that page, with no success.

Update: I added a separate action on to run entity_save, and set its weight at 0. The original rule's weight is 5 so it should run after the force save is complete.  Same result, and it takes twice as long now.

0 ms Reacting on event After updating existing content.
16.051 ms Evaluating conditions of rule Force save after update. [edit]
16.083 ms AND evaluated to TRUE.
    0 ms Rule Force save after update fires.
    0.29 ms Evaluating the action entity_save. [edit]
    2.513 ms Saved node of type node.
        0 ms Reacting on event After updating existing content.
        0.386 ms Not evaluating reaction rule Force save after update to prevent recursion. [edit]
        0.431 ms Evaluating conditions of rule TEST rule on save content. [edit]
        0.448 ms AND evaluated to TRUE.
            0 ms Rule TEST rule on save content fires.
            0.161 ms Evaluating the action php_eval. [edit]
            1954.427 ms Rule TEST rule on save content has fired.
        1954.943 ms Finished reacting on event After updating existing content.
    1984.676 ms Rule Force save after update has fired.
2000.878 ms Evaluating conditions of rule TEST rule on save content. [edit]
2000.902 ms AND evaluated to TRUE.
    0 ms Rule TEST rule on save content fires.
    0.199 ms Evaluating the action php_eval. [edit]
    2422.949 ms Rule TEST rule on save content has fired.
4423.939 ms Finished reacting on event After updating existing content.


texts: How do you position a custom search box in the main menu?

texts: I'm using the Drupal 7 Mayo theme for my site. The theme comes with a search box that you can place in the header but no where else, so I made a custom search box block, which I would like to place to the right of the main menu bar, which has a horizontal list of dropdown menu links. When I try to move the search block to the main menu, however, it either pushes the links to a line below or appears on a line below the links depending on how I set the weight. I can't get them to match up. Is there a way to fix this?


texts: The file names are not transliterated on upload

texts:
I am using Drupal 7 and have transliteration module enabled.

I have a file field and I want to have the names of the uploaded files to be transliterated on upload.

The url alias for the nodes are well transliterated. But the file names are not.

I checked the settings for file system. The current settings are:

Transliterate file names during upload.(checked)
Lowercase transliterated file names. (checked)

If I "Transliterate existing file names" (admin/config/media/file-system/transliteration) then the names of the files I have already uploaded are transliterated. But still, when I upload new files, the file names are not transliterated.

Any ideas why the names are not translated on upload?


texts: How to insert an RTMP url from an adobe streaming server (rtmp://example.com/myvideo.flv) in drupal 7?

texts:
I need to create a video gallery and would like some advice on how to view flash videos on drupal 7.

The url I have to insert are rtmp (rtmp://example.com/myvideo.flv).

Any ideas on what modules to install and the steps to follow?

I read on the previous questions about flowplayer but it's only supported on Drupal 6.

Many thanks for your help.


texts: How to add 'odd' or 'even' class in each row of a Views Table output?

texts:
I'd like to take advantage of Drupal's default CSS for even/odd rows in a table.
I use Views to list the content of a custom entity with 'Table' format.
I don't know where to put this setting...

Thanks in advance

P.-S. I use Drupal 8 (8.1.2)


texts: How do I display line breaks from a text-area in a table?

texts:
I have a webform with a text-area field. I want to display the submitted values in a custom table.
I am using this code to be able to display line breaks, and keep the input secure.
$rows[] = ['Questions', Markup::create(nl2br(Html::escape($data['question'])))];

Is there any better solution?


texts: Is it possible to create an action with derivatives?

texts:
Is it possible to create an action in Drupal 8 and point it at a deriver class to generate them automatically?

For example with Custom Publishing Options I have a ConfigurableActionBase action that lets a user create an advanced action, select the publishing option and the value, and save the action.

Ideally, I would like to have a generic action derived from all existing publishing options so that admins don't have to create the action manually every time they add a new custom publishing option. Along with that, if they deleted the entity, I would want the action to be removed as well.

I was able to create a class extended DeriverBase and define plugin derivatives, but was having issues getting it to pick up in my class extending ActionBase with deriver set in the annotation. My example code is on my home laptop, will post it when I have a chance.


texts: Move timezone field in user/%/edit field

texts: I want to move timezone field in user/%/edit form. I have used$form['#weight'] in hook_form_alter() and $page['#weight'] in hook_page_alter(), but not working.


texts:
I have a node type with multiple text fields. The majority of these are designed to fit very specific templates, and have fixed height and width, and are generally quite small.  The full CKE interface is too much of a good thing for these fields, so I made a different "Text Format," and tied it to a distinct Wysiwyg profile, "Full HTML (Simple)"

All of this is super, except that the default is still the default, and unless the user CHOOSES the other profile... it serves no purpose whatsoever.  These same users have access to multiple filters, so the obvious option is out.

I understand limiting the profiles by roles... and I half understand Filtering by Node Type... but I don't understand not limiting them by field.

I checked modules and it looks like Better Formats is on the way to doing it for 7, but I can't see any modules out there that ready for prime time.

I can't be the first person who has desired this.  Is there a hiccup in my logic, or a methodology I should be considering?


texts: How can I send mail containing rendered entity from referenced field?

texts:
How do I code a function for sending mail containing a rendered entity that is referenced from a field?
I have content type A that contains static information, and content type B that users create and reference to the corresponding content type A node instead of writing everything manually. In a custom module I have some code for sending mail notifications containing info in a content type B node, but now the client wants some info from the referenced content type A node.
The line of code that I have a problem is this:
$avtal_id = $node->field_avtalsnummer['und'][0]['value'];

field_avtalsnummer is the reference field in content type B that points to a node of type A and $avtal_id is used in the mail (plain-text). All other fields in the custom module works fine, but for some reason that I don't fully understand I can't get this to work. If I change value to target_id i get the node ID but I can't get the value. Title does not work either. Do I need some code to load the entity first? The optimal solution for me would be to get the info from the referenced field and to display a custom view mode so that I can customise the mail notification accordingly to my clients demands, but I can't even get the value of of the referenced field to work so I'm running out of ideas. Help is very appreciated!


texts: Comment.tpl.php how to add a link back to the node

texts:
In the comment.tpl.php I've shown the comment parent node title by:

$node->title

I need to make this title link back to the parent node:

$node->$node_url

But this doesn't work. How should I do that?


texts:
I have quite a big E-Mail sent out by webforms. To display the Form, I use a lot of HTML / Markup fields. Mainly for Product descriptions and further informations relevant to the user by filling out the form. I use a Webform Table Element to display all of this stuff.

In the end it looks something like that:

col1       | col2  | col3    | col4
-------------------------------------------
textfield1 | Text1 | Text1_2 | textfield1_2
-------------------------------------------
textfield2 | Text2 | Text2_2 | textfield2_2
-------------------------------------------
textfield3 | Text3 | Text3_2 | textfield3_2
-------------------------------------------

Now, I need to send out an E-Mail and calculate the values and also print the values of the Text Elements.

My wish would be to use computed twig fields to assemble the line how I need it in the end.

{{ data.textfield1 }} x {{ Text1 }} - {{ Text1_2 }} = {{ data.textfield1 * data.textfield1_2 }}

Calculations and everything works well. I'm just not able to reuse the Text stored in a HTML Element. So my question is, how can I access this HTML / Text?


texts: How do I use another field inside view as the base table?

texts:
I would like to know how I may use a database field from a custom module to build queries on.

By default, using content view starts off querying from the "node" table. I would love to have the Views module to query from my own custom table.

I have tried using hook_views_data() and set a base table, but it all came to nought so far.


texts:
I want to display a Flash file from a view. I have a content type with a file field that I use to create a node and submit a Flash file (.swf).

Then I use a view to create a block showing the content of these content type nodes. I get the Flash files URL and use the code below to print it - but, no Flash is printed!

Why doesnt this work? It's HTML, isn't it? And Views should support it?

<embed id="[title]" width="190" height="285" wmode="transparent" loop="true" scale="noscale" allowscriptaccess="sameDomain" quality="high" bgcolor="#FFFFFF" name="[title]" src="[field_ad_flash]" type="application/x-shockwave-flash">


texts: How to add the proper javascript to a page for using the Chartbeat module?

texts:
Has anyone successfully used the Chartbeat module with Drupal to get the analytics statistics?

It doesn't seem to work for me. I don't get the proper javascript added to the page.


texts: Twig escapes tags when using raw value in template

texts:
I am printing fields in a node template, but Twig is escaping my tags and ruining my day.

My .tpl looks like this:

{{ content.field_myfield.0 }}

I want to strip all tags from the original field and then "wrap" the field in a paragraph tag with the title class.  I found out how to get the raw value without tags based on this question.

However, this is the HTML that is actually output:

When you wish upon a star

What am I doing wrong?


texts: Webform populate text component with encoded url values

texts:
How to populate a webform component with encoded values. For exampmple my url http://example.com/abc?submitted%5Bthis%5D=1

I tried to use token [current-page:query:this] but it doesnt work.


texts:
I wanted to download Image module, but I notice that it's not for Drupal 7. Is there some alternative I can use in Drupal 7?

thank you


texts: Update hook - is it possible to generate success or failure message on operation success?

texts:
I would like to be clear on how to indicate success (or failure) messages in update hooks, when a step completes successfully (not using &sandbox).

I vaguely remember seing a post on this (probably here) but all the examples I searched for do not show any messages in the update hook.


texts: How can I understand when hook_form_alter() is called?

texts:
In Drupal 8, hook_form_alter() is invoked multiple times: at page load, submission, after executing custom submission handlers, and back to form action.
How can I see at which stage hook_form_alter() is invoked?


texts:
In Drupal 8, I use this code inside my buildForm() method:

$form['medias']['file'] = array(
  '#title' => t('Image'),
  '#type' => 'managed_file',
  '#upload_location' => 'public://image_example_images/',
  '#multiple' => true,
);

(Bad) Result: http://i.stack.imgur.com/ju0ZU.png

I would like know if it's possible to use a plugin of type "field widget" inside BuildForm() for call and use a field of Image type provided by the core of Drupal:

Thanks.


texts:
I have a content type with 100+ fields with lots of required fields. I am using the 7.x-1.4+8-dev version of the Save Draft module, with the patch which allows saving a draft without all required fields filled.

It appears that saving a draft works only once. Is it possible to save a draft more than once?


texts: How can i remove duplicate encoding meta tag

texts:
I have repeated charset meta tag in all my drupal pages. I have been using my metatag module.

To optimize SEO results, this error is reported as primary to fix.

I have used jquery(ready & load event) to remove from client side, removes in dom element but the page source shows 2 charsets.

No configuration in meta tag refers to charset.


texts: How to highlight location on an OpenLayers view

texts:
I have a view of locations displayed with OpenLayers. The map, with plot points, is displayed in a left column, and rows of the locations are displayed in a right column.  When a user clicks on one of the locations, I want that row to highlight, and to highlight the plot point to the left.  I also want to record that location ID in the user object as a location preference.

Can I simply do this with AJAX?


texts:
I need to create the following to a menu system in drupal 7. I want to be able to create a href that is not connected to a content type. Is this possible?

link

link

I need this link to not be attached to a content type

link

link


texts: Coupon code generation batch fails but only after 3rd time

texts:
So there is a coupon code batch generator in commerce
https://git.drupalcode.org/project/commerce/-/blob/8.x-2.x/modules/promotion/src/Form/CouponGenerateForm.php
that I use and works fine until I use it on production server, where I make 2 batches of 1000 coupons and then after that each batch fails(on the same promotion). I tried it even manually to create (with for loop) and it just fails if I loop more then 15 coupons.
$coupon_storage = \Drupal::entityTypeManager()->getStorage('commerce_promotion_coupon');
$coupon = $coupon_storage->create(['code' => $code,] + $coupon_values);
$coupon->save();

Basically it is this code that creates coupons. Problem is I can't get any logs that point to the problem. No drupal error, no php-fpm problem, checked memory consumption and seems fine I am thinking it could be some DB problem as we are using Amazon RDS on production as it is main difference between production and staging (where we have local DB and no problems) but even some RDS logs didn't show some problems, so I am a bit stuck here.
Erros is classic batch error with no particular info.
An AJAX HTTP error occurred.
HTTP Result Code: 503
Debugging information follows.
Path: /batch?id=233123&op=do_nojs&op=do
StatusText: error
ResponseText:
503 Service Unavailable
Error 503 Service Unavailable
Service Unavailable
Guru Mediation:
Details: cache-vie21647-VIE 1594893781 637262210
Varnish cache server


texts: How to disable or make fields unpublished, but not delete them

texts: I have some fields I need to disable from user registration, but no delete them, just make them unpublished or disable them temporarily, is there a way to do that?


texts:
I have a content type with 5 taxonomies, each with 50 terms (checkbox). All of them are available for user to choose when creating node.

It looks really long and not quite user friendly.

So i am looking a module that can make this look nice. Table, inline, anything but default would look better.


texts:
When I save my Custom Entity Type I get an error. I tried several different things. The code looks valid to me.

  Error: Cannot unset string offsets in Drupal\Core\Field\WidgetBase->extractFormValues() (line 367 of core/lib/Drupal/Core/Field/WidgetBase.php).

This is my annotation.

/**
 * @ContentEntityType(
 *   id = "email_confirm_redirect",
 *   label = @Translation("Redirect entity"),
 *   admin_permission = "administer email confirm redirect entity",
 *   base_table = "email_confirm_redirect",
 *   translatable = TRUE,
 *   handlers = {
 *     "list_builder" = "Drupal\email_confirm_redirect\Entity\Controller\RedirectListBuilder",
 *     "form" = {
 *       "add" = "Drupal\email_confirm_redirect\Form\RedirectForm",
 *       "edit" = "Drupal\email_confirm_redirect\Form\RedirectForm",
 *       "delete" = "Drupal\email_confirm_redirect\Form\RedirectDeleteForm",
 *     },
 *     "access" = "Drupal\email_confirm_redirect\RedirectAccessControlHandler",
 *   },
 *   list_cache_contexts = { "user" },
 *   entity_keys = {
 *     "id" = "id",
 *     "label" = "title",
 *     "uuid" = "uuid",
 *     "langcode" = "langcode",
 *     "admin_name" = "admin_name",
 *   },
 *   links = {
 *     "edit-form" = "/admin/email_confirm_redirect/{email_confirm_redirect_entity}/edit",
 *     "delete-form" = "/admin/email_confirm_redirect/{email_confirm_redirect_entity}/delete",
 *     "collection" = "/admin/structure/email_confirm_redirect/list"
 *   },
 * )
 */

This is the code I am using.

public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
  // Standard field, used as unique if primary index.
  $fields['id'] = BaseFieldDefinition::create('integer')
    ->setLabel(t('ID'))
    ->setDescription(t('The ID of the redirect entity.'))
    ->setReadOnly(TRUE);

  // Standard field, unique outside of the scope of the current project.
  $fields['uuid'] = BaseFieldDefinition::create('uuid')
    ->setLabel(t('UUID'))
    ->setDescription(t('The UUID of the redirect entity.'))
    ->setReadOnly(TRUE);

  $fields['langcode'] = BaseFieldDefinition::create('language')
    ->setLabel(t('Language'))
    ->setTranslatable(true)
    ->setDescription(t('The redirect language code.'))
    ->setDisplayOptions('form', array('type' => 'language_select', 'weight' => 2));

  $fields['admin_name'] = BaseFieldDefinition::create('string')
    ->setLabel(t('Administrative Name'))
    ->setDescription(t('The name for the redirect (shown just in admin)'))
    ->setRequired(TRUE)
    ->setSettings(['max_length' => 255, 'text_processing' => 0])
    ->setDefaultValue(NULL)
    ->setDisplayOptions('form', ['type' => 'string_textfield', 'weight' => -5])
    ->setDisplayConfigurable('form', FALSE)
    ->setDisplayConfigurable('view', FALSE);
}

I also don't see the language selector on the edit/add form.


texts: ContentEntityForm buildForm method parent out of memory

texts:
I have the following issue with my form class that extends the ContentEntityForm class.

When calling the parent buildForm which is needed my system runs out of memory.

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {
    $form = parent::buildForm($form, $form_state);
    // Here is already runs of memory. $form is never initiated.

    /* @var $entity \Drupal\sg_configuration_rule\Entity\ConfigurationRule */
    $entity = $this->entity;

    $form_state->set('old_cron_value', $entity->get('cron_settings')->first()->value);

    $type = FALSE;

    if (!$entity->isNew()) {
      $type = $entity->getPluginInstance()->getPluginId();
    }

    if ($entity->isNew()) {
      $type = \Drupal::request()->query->get('type');
      if (!$type) {
        return new RedirectResponse(Url::fromRoute('configuration_rule.add_form_step1')->toString());
      }
    }

    if ($type) {
      try {
        /** @var \Drupal\sg_base_api\Plugin\BaseApiPluginInterface $enabled_api */
        $enabled_api = $this->baseApiPluginManager->createInstance($type);
      }
      catch (PluginException $exception) {
        LoggerService::error($exception->getMessage());
        return new RedirectResponse(Url::fromRoute('configuration_rule.add_form_step1')->toString());
      }

      $enabled_api->configRuleForm($form, $entity);

      $form['plugin_type']['widget'][0]['value']['#value'] = $type;
      $form['plugin_type']['widget'][0]['value']['#access'] = FALSE;
      $form['plugin_type']['widget'][0]['value']['#disabled'] = TRUE;
      $form['server_node']['widget']['#options'] = $this->getServerNodesByType($enabled_api->entityType());
    }

    $form['user_id']['#access'] = FALSE;

    return $form;
  }

When i check the parent function i noticed that the line:

$form = $this->form($form, $form_state); is causing this in the class EntityForm(Core method).

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {
    // During the initial form build, add this form object to the form state and
    // allow for initial preparation before form building and processing.
    if (!$form_state->has('entity_form_initialized')) {
      $this->init($form_state);
    }

    // Ensure that edit forms have the correct cacheability metadata so they can
    // be cached.
    if (!$this->entity->isNew()) {
      \Drupal::service('renderer')->addCacheableDependency($form, $this->entity);
    }

    // Retrieve the form array using the possibly updated entity in form state.
    // This is causing my memory timeout.
    $form = $this->form($form, $form_state);

    // Retrieve and add the form actions array.
    $actions = $this->actionsElement($form, $form_state);
    if (!empty($actions)) {
      $form['actions'] = $actions;
    }

    return $form;
  }

If i comment that line out it is working fine but this is needed to save my values in config. Also this is core and should work.

Anyone else have this problem and knows the solutions to this?

Thanks.


texts:
I am using the default template and I want the background color of the header change when a user signs in.

I know I will need to write a simple if statement like if (user_is_logged_in()) { } somewhere, but I don't know where to place it.


texts: What hook can alter fully rendered html?

texts:
I'm rendering some JSON using Views and Views Datasource and due to a bug in Views Datasource, I can't seem to get the output rendered properly. So, I'm looking for a workaround.

What hook can I implement in my theme or module that will give me the final string that is about to sent back to the browser that will give me one last chance to alter it?

EDIT: I was in a hurry and worded that poorly. When I say the page won't render properly, I mean that the bug in Views Datasource doesn't use the proper data formatters for the data fields. I'm getting JSON back just fine, but some of the values within the JSON are not properly processed by the relevant module formatters. In this example, the Video field can contain a Video URL and a Thumbnail Image URL. The view is configured to display a Thumbnail Image URL, but due to the bug in Views Datasource, it is displaying the Video URL instead.

I can't just change the render array, because Views Datasource is not generating its output using a render array.


texts: Views are disappearing randomly; always needing to flush caches

texts:
I am writing a module that has 2 views in code. At first, I pasted the code that was exported from views directly into hook_views_default_views() like so...

function MY_MODULE_views_default_views() {
  $views = array();

  // Copy and pasted code from views export here...

  $views[$view->name] = $view;
  return $views;
}

After installing the module, the only way to get the views to show up would be to run cron and then flush the caches. I tried just running cron, or just flushing caches, and it would only work if I ran them both in that order. Once the views showed up, I could go along with things fine for a little while, then randomly the view would disappear again. I could not figure out a pattern to why they would disappear. Flushing caches would mostly fix it. Sometimes I had to flush caches two or three times or run cron and flush caches to get the views to appear again.

I searched around for some help and was able to find this post... A whole view disappears. This seems to be a similar problem. The function is too long and each view needs to be split into separate files. Okay, I did that and now my code looks like this...

// Files located in "my_module/views":
my_module.view_1.view
my_module.view_2.view

/**
 * Implementation of hook_views_default_views().
 */
function MY_MODULE_views_default_views() {
  $views = array();
  $files = file_scan_directory(drupal_get_path('module', 'MY_MODULE'). '/views', '/.*\.view$/');
  foreach ($files as $filepath => $file) {
    require $filepath;
    if (isset($view)) {
      $views[$view->name] = $view;
    }
  }
  return $views;
}

This is a nice solution as it makes adding new views very easy and clean. However, I am having the exact same experience as before. After installing the module, it still takes a cron run and a cache flush for the views to show, which they eventually do, but then they still disappear randomly. The only way to get them back is to flushes the caches (sometimes several times), or run cron and flush caches.

I'm feeling pretty stuck here. If anyone would be so kind as to offer some guidance, that would be most appreciated. Thank you.


texts:
I'm getting data from a source. In the following example, there is no data in drupal database and there are 4 source "nodes" that I will import. The content type is set to create revisions.

So, first time I import data this is what I get:

The update date is 22/11/2015 12:00 for all 4 nodes and views has to show them all.

After half an hour, I make another import from the same source but, data 2 was deleted, so, It will not be imported.

I get this:

At drupal db (green block), you can see that the update date was not changed, only the other 3 nodes were changed.

Is some way (that I don't know how), I need my view to show only nodes 1, 3 and 4, basically, the latest that were updated.

Important to note that, no matter how many nodes I import, the update date will always be the same.
Also, I can add fields to my content type and set values when the nodes are first imported or updated and try to use that as filters.

How can I implement this with views? Or, if not possible with views, any other suggestion?


texts: Override display of content type using Views

texts:
How can I use the Views module to override the output of a content type's display?

So that when a user visits a page/node created with this content type, it renders a view instead


texts: Possible to have 2 contextual filters with "or" rather than "and"?

texts:
I would like to create a view that shows all nodes created by the currently logged in user OR where the currently logged in user has commented on.

D6 had a views_or module but it's not ported to 7.

Are there any simple solutions?


texts: Drupal 7: Using Views to display articles with a taxonomy that is also selected for the current user

texts:
I'm trying to make a View that displays all articles having the same value in an taxonomy field as the current user has in its taxonomy field (taxonomy is "Work Location" and I want to display the work location news)

For that I created the taxonomy and added several locations. Then I added a field based on this taxonomy to the user and to the article content type.

Now I'm trying to create the View but I just can't figure it out.


texts:
I am just starting out making my module and already running into 2 problems, I believe this is being cause because the form is in a block but I am not entirely sure. This is what I have in my .module file, as you can see I have the function to output the drupal message upon submission however it simply does not do anything. I also get this error when I have the variables in my function.

Notice: Undefined variable: form in zillow_block_view() (line 33

and

Deprecated function: Call-time pass-by-reference has been deprecated in drupal_load() (line 933 of C:\xampp\htdocs\drupal\includes\bootstrap.inc).

function zillow_block_info(){
        $blocks['zillow_block'] = array(
            'info' => t('Zillow Block'),
        );
        return $blocks;
    }

function zillow_block_view($delta = ''){
    $block = array();
        switch ($delta){
    case 'zillow_block';
        $block['subject'] = t('Zillow Block');
        $block['content'] = zillow_form($form, &$zinfo);
    break;
    }
    return $block;
}

function zillow_form($form, &$zinfo){

    $form['description'] = array(
        '#type' => 'item',
        '#title' => t('Get your mortgage rates'),
    );
    $form['rates'] = array(
        '#type' => 'fieldset',
        '#title' => t('Mortgage Rates'),
        '#collapsiable' => TRUE,
        '#collapsed' => FALSE,
    );
    $form['rates']['street'] = array(
        '#type' => 'textfield',
        '#title' => t('Street Address'),
        '#default_value' => 'Street Address',
    );
    $form['rates']['city'] = array(
        '#type' => 'textfield',
        '#title' => t('City'),
        '#default_value' => 'City',
    );
    $form['rates']['zip'] = array(
        '#type' => 'textfield',
        '#title' => t('Zip Code'),
        '#required' => TRUE,
        '#default_value' => "Zip Code",
        '#description' => 'Please enter your zip code',
        '#size' => 5,
        '#maxlength' => 5,
    );
    $form['submit'] = array(
        '#type' => 'submit',
        '#value' => 'Submit',
    );
    return $form;
}

function zillow_submit_info($form, &$zinfo){
        drupal_set_message('this is the info the form has submitted. zipcode=@zipcode',
        array('@zipcode'=>$zinfo['values']['zip']));
    }

any help is appreciated.


texts: Is it safe for me to use _taxonomy_title_get_title() implemented by a third-party module?

texts:
I have installed the Taxonomy Title module 7.x-1.5 in order to change the grey content title on top of certain taxonomy pages. The module added a new field (Term page heading) where I add my custom titles. The title is changed as expected. Now I also need to use that same custom title in certain nodes, so I need to find out how to get the value added in that field.

After a look at the module code, I tried using _taxonomy_title_get_title($tid), which works. Is it safe for me to use this function?


texts: How to automatically assign a (sequential) number to a user-created node

texts: I'm designing a website for a group of academics.  I've created a content type, called "Preprints," where users enter information about a paper they have recently submitted to an outside journal for publication. When created, these nodes are then listed on a Views page, also called "Preprints." The users, however, would like some way of tracking the order in which they submit their Preprint. Thus, I'd like to figure out some way of automatically assigning each node a number or a code. (For example, the first paper of the year would be assigned the code LPS13001, the second would be LPS13002, and so on.)  My first thought was to do this through a custom field, but I haven't been able to figure this out. Any help would be greatly appreciated!


texts: How can I remove javascript from everywhere but the front page?

texts:
I tried using this in template.php

function MYTHEME_js_alter(&$javascript) {
  if ($!is_front) {
    unset($javascript['path/to/script.js']);
  }
}

but it doesn't work. Performance wise, would it be as good to have the javascript that's on every page in theme.info, then use drupal_add_js on the front page instead?


texts: Make sure that the overriding service 'wins'

texts:
Setup
I have multiple sites that are very similar and therefore share the same code base. I have a custom module common with functionality common to all sites. Then for each site I have a specific module site_a, site_b etc where site specific code resides.
I want to create custom services such that common has a default implementation that site_a can override if necessary.
Specific use case
On user creation, for example, the different sites need to run mostly the same routines, but not entirely. In this case I would place each specific routine as methods in Drupal\common\Service\UserCreationService.php and call them one at a time from hook_user_insert():
$user_creation_service = \Drupal::service('my_module.user_creation_service');
$user_insert_service->routine_1();
$user_insert_service->routine_2();
// etc

If site A needs a different routine I would let Drupal\site_a\Service\UserCreationService.php extend Drupal\common\Service\UserCreationService.php and replace the relevant method. Of course this functionality could easily be achieved by simply reimplementing the same hook in site_a, but I find the service method much clearer and with less boilerplate.
Minimal example
There are two ways to override services as far as I can tell from this documentation. One is to implement the MyModuleServiceProvider::alter(), another (for core services) is to specify (an override for) the service in my_module.services.yml. The second method seems to also work for custom services, which is was prompted this question.
Consider this example:
# File: modules/common/common.services.yml
services:
  common.test_service:
    class: Drupal\common\Service\TestService

// File: modules/common/src/Service/TestService.php
namespace Drupal\common\Service;

class TestService {
  public function sayMyName() {
    return 'common';
  }
}

# File: modules/site_a/site_a.services.yml
services:
  common.test_service:
    class: Drupal\site_a\Service\TestService

// File: modules/site_a/src/Service/TestService.php
namespace Drupal\site_a\Service;

class TestService extends \Drupal\common\Service\TestService {
  public function sayMyName() {
    return 'site_a';
  }
}

Now echo \Drupal::service('common.test_service')->sayMyName() outputs 'common' when site_a is uninstalled and outputs 'site_a' when site_a is installed - exactly as wanted! But it seems a bit flaky, as the linked documentation says:

If multiple modules swap the same service, then neither module can predict if their swapped service will win eventually.

This should not be a problem because I define a service in one module and override it in another (even though in this example I do it in the services.yml file). But I don't completely trust that this is just a lucky coincidence when the services share the same name.
I would much prefer if I could explicitly set the hierarchy and specify that the service i site_a overrides a service from common, but this does not seem to be possible.
Question
How can I be absolutely sure that it's the service from site_a that is fetched from the service container and not the one from common? Do I have to use MyModuleServiceProvider::alter() instead of the services.yml file, and even then can I make sure that everything works?
Bonus question: Is this best practice, or should I be doing something else?


texts: How to save an uploaded image in an admin form?

texts:
I wrote the following module to upload a background image. My problem is, that my submit function is not called, though the pic is uploaded and showed in the block until the next cleanup is coming.The managed file table shows status 0...what should be 1 as far as i know.

Here is the Code of my Module: Whats the mistake?

function backgroundimage_block_info() {
    // This example comes from node.module.
    $blocks['backgroundimage'] = array(
        'info' => t('Background Image'),
    );

    return $blocks;
}
function backgroundimage_block_view($delta = '') {
    $fid_now=variable_get('backgroundimage');
    dpm($fid_now);
    $file_obj = file_load($fid_now);

    $bg_img_url = file_create_url($file_obj->uri);

    // This example is adapted from node.module.
    $block = array();

    switch ($delta) {
        case 'backgroundimage':
            $block['subject'] ="imagebackgroundblock";
            $block['content'] ="

";

            break;

    }
    return $block;
}
function backgroundimage_admin() {
    $form = array();

    $form['backgroundimage'] = array(
        '#type' => 'managed_file',
        '#name' => 'backgroundimage_image',
        '#title' => t('upload image, huh!'),
        '#default_value' => variable_get('backgroundimage', ''),
        '#description' => t("Here you can upload an image to the background!"),
        '#required' => TRUE,
        '#upload_location' => 'public://backgroundimage/'
    );

    return system_settings_form($form);
}
function backgroundimage_form_submit($form, $form_state) {
    dpm("yeah"); // is not being called!
    $form['backgroundimage']['#file']->status = FILE_STATUS_PERMANENT;
    file_save($form['backgroundimage']['#file']);
}

function backgroundimage_menu() {

    $items = array();

    $items['admin/settings/backgroundimage'] = array(
        'title' => 'Settings Background Image',
        'description' => 'Image upload',
        'page callback' => 'drupal_get_form',
        'page arguments' => array('backgroundimage_admin'),
        'access arguments' => array('administer backgroundimage settings'),
        'type' => MENU_NORMAL_ITEM,
    );

    return $items;
}

?>

Thanks a lot!


texts: Views : hide thumbnail for all but one content

texts: Ive created a View called "most recent articles" that are made up of 4 contents. I have the thumbnail displayed along with title, body and tags for each content. This is sorted by Most recent article by published date. How can I only display the thumbnail for the latest content (1) but the other 3 articles not display the thumbnail at all?


texts: Convert Database object into database URL string

texts:
I've define my own database connection in my Drupal settings file as follow:

$databases['migrate']['default'] = array(
  'driver' => 'mysql',
  'database' => 'drupal',
  'username' => 'root',
  'password' => 'root',
  'host' => 'localhost',
  'prefix' => '',
);

To read that in Database object format, you can run:

drush eval 'print_r(Database::getConnectionInfo("default", "migrate"));'

And now I would like to have the string representation (similar to $db_url in Drupal 6) to use it in some drush commands on that database e.g. drush --db-url=${DB_URL} status.

So I would like to convert above Database array format into database URL string format (e.g. mysql://root:root@localhost/drupal).

Is there any easy way of doing that via function, PHP code or drush?

Additional info:

There is update_parse_db_url() function, but it's converting database connection URLs and return D7 compatible array.


texts: Views Slideshow - showing only one slide

texts:
I've the content type, from which I want to take one field: title and present it as a block somewhere on the page. Sounds rather easy, but maybe my brain has melted already.

I installed Views Slideshow, created new view and it seems to work. To some degree, because it's only showing me one slide (title) and when it's fading, nothing new appears. When I choose the format for example to unformatted list, it shows all the titles it should, but in slideshow format it just doesn't work. What I'm missing here?

This is how it looks right now:


texts: How to query the Database logs and create summary reports and/or charts of them?

texts:
Is there a module for querying and creating summary reports of the Database logs?

I need something that can create an equivalent of SQL Group by queries on the Database logs, eg, group by type, severity, count, IPs etc, and create views and possibly graphs on them.


texts: How to get tid on behalf of node id (nid) in Drupal 8?

texts:
I am new in Drupal 8. I have created a node with category (taxonomy). Now I don't understand how to get tid by using nid. I am using $node->body->value to get the body field value and use {{ body }}. But to get category id if I use $node->field_category->value, it will display Null in debugging mode.

function THEME_preprocess_node(&$variables) {
  $node = \Drupal::routeMatch()->getParameter('node');
  $variables['body'] = $node->body->value;    // Working fine
  $cat_id = $node->field_category->value;    // Its showing null
  kint($cat_id);
}

So can anyone please tell me how can I get the category id (tid) of a node?


texts: In Drupal 7, how do you git clone a module project quickly?

texts:
There doesnt seem to be any good documentation on a quick way to git clone a module project. I have already read this: https://drupal.org/project/examples/git-instructions

The following format does not work for me:

  git clone --branch 7.x-1.x http://git.drupal.org/project/examples.git

I am getting this error:

Is there a way to do a git clone quickly by copying a url without having to put in --branch 7.x-1.x versions... or better yet is there a drush command to do a git clone? All i want to do right now is do a git clone of a project and provide a patch to the maintainer, but im hitting resistance setting this up.


texts: Entityform send uploaded files as link and not as an email attachment

texts: I am using Entityform to send email notification to admin when visitors submit a form with an uploaded PDF file. How do you get the uploaded file to be provided as an email attachment and not as link?


texts: Individual row for each node field in a view

texts:
I'm trying to create a view of a node's fields, primarily a list of images and node references to be rendered with a views slideshow.

The view has two fields listed, an image field and a reference. I'm showing fields, without default file wrappers, and formatting that with views slideshow. The slideshow settings doesn't have a grouping option, as it seems to provide more of skin styling, and cycling options.

My problem is each row is spitting back 2 items per row. Example, if I have a node with pictures: p1, p2, p3 and reference R1, R2.

The results of the view will be something like this:
P1, R1
P1, R2
P2, R1
P2, R3

And on. What I need is just a plain list of the images and references, not in a matrix like result, so something more like: P1, P2, P3, R1, R2.

I did take a look at the query that the view is using, which looks like:

SELECT DISTINCT node.nid AS nid, field_data_field_images.delta AS field_data_field_images_delta, field_data_field_images.language AS field_data_field_images_language, field_data_field_images.bundle AS field_data_field_images_bundle, field_data_field_images.field_images_fid AS field_data_field_images_field_images_fid, field_data_field_images.field_images_alt AS field_data_field_images_field_images_alt, field_data_field_images.field_images_title AS field_data_field_images_field_images_title, field_data_field_images.field_images_width AS field_data_field_images_field_images_width, field_data_field_images.field_images_height AS field_data_field_images_field_images_height, field_data_field_sia_image.delta AS field_data_field_sia_image_delta, field_data_field_sia_image.language AS field_data_field_sia_image_language, field_data_field_sia_image.bundle AS field_data_field_sia_image_bundle, field_data_field_sia_image.field_sia_image_nid AS field_data_field_sia_image_field_sia_image_nid, 'node' AS field_data_field_images_node_entity_type, 'node' AS field_data_field_sia_image_node_entity_type
FROM
{node} node
LEFT JOIN {field_data_field_images} field_data_field_images ON node.nid = field_data_field_images.entity_id AND (field_data_field_images.entity_type = 'node' AND field_data_field_images.deleted = '0')
LEFT JOIN {field_data_field_sia_image} field_data_field_sia_image ON node.nid = field_data_field_sia_image.entity_id AND (field_data_field_sia_image.entity_type = 'node' AND field_data_field_sia_image.deleted = '0')
WHERE (( (node.type IN  ('blog_post', 'sia_inline_slideshow')) AND (node.nid = '77603' ) ))

I ran that through mysql workbench to look at the results it is spiting back. Even with distinct, I'm getting multiple responses from one image field. It looks like the issue is there are multiple instances of field_data_field_[fieldname]field[fieldname]_nid. Each image also has a single incremented delta.

Question is, is there a way in views to just get the distinct values, or do I need to use the template system to override the output and remove the duplicates?


texts: Problem migrating Entity Reference fields with Drupal 7

texts:
I cannot migrate entity reference fields Migrate . I am following the examples online i.e.

$this->addFieldMapping('my_reference_field','bla')->sourceMigration('BooksNode')->separator(',');

The idea is for a book lending data. I can lend several books to one person (not a user on my site, just a regular content type).

Not sure what I am missing but nothing gets mapped.

I should add that the primary key on my Books table (in MySQL) is a composite one consisting of two fields id and unique_id. Do I need to add that somehow to :

$this->addFieldMapping('my_reference_field','bla')->sourceMigration('BooksNode')->separator(',');

maybe

$this->addFieldMapping('my_reference_field',array('id', 'unique_id'))->sourceMigration('BooksNode')->separator(',');

thx in advance


texts: I have successfully added Meta Tags to the front page of my Drupal 7 site and to pages. However I can't seem to add meta tags to blocks? How do I do this?


texts: Display specific nodes on specific pages

texts:
How do I display specific nodes from a view on specific pages?

For example, I create a CCK field ("Display on node id:") for the content type Ads, and put there IDs of content type Basic page where I want display this Ads.

Is there to achieve this without additional modules?


texts: Problem with aggregated CSS/JS on flush cache

texts:
We are using Varnish and Pressflow (v6.30).  Every time we flush cache in Drupal, we encounter problems where browsers can not get requested CCS/JS aggregate files as they do not exist.  We have found that if we flush Drupal cache and then immediately flush varnish cache, problem is fixed.

Anybody else had this issue?   And is there a module (purge or similar) which automatically handles Varnish flush cache with Drupal cache?


texts: How do I dynamically populate a select field?

texts:
this question comes quite often but I couldn't make it work to that point.
My problem is simple, I have a 2 level taxonomy, I have 2 select fields, one is populated with the parent taxonomy and the second should be populated by its children when one parent is selected.

But I'm a bit confused. I followed the developer example with the check-boxes, but still. Also, this happens in hook_form_alter() and since I'm quite new to Drupal 7, I have to set the options with the ['und'] prefix, but that also troubles my mind because when I omit the ['und'] part when I try to save the node, an error says Illegal choice.

This is my first select field.

  //Field TYPE
  $form['field_type']['und']['#options'] = std_to_array($vocabulary_nudge_all);
  $form['field_type']['#ajax'] = array(
    'callback' => 'ajax_nudge_taxonomy_selected_callback',
    'wrapper' => 'select-target-div',
    'method' => 'replace',
    'effect' => 'fade',
  );

This is the AJAX callback function where I tried to get the field_type value, but I read somewhere that I couldn't use $form_state in a form hook.

function ajax_nudge_taxonomy_selected_callback($form, $form_state) {
  return $form['field_target_select'];
}

Using $form, all I could think of was using #delta.

$selected = $form['field_type']['und']['#delta']

In the second select with a prefix, a suffix, and a visible condition, I am using the following code.

//Field Target SELECT
$form['field_target_select']['#weight'] = '0';
$form['field_target_select']['#prefix'] = '
';
$form['field_target_select']['#suffix'] = '
';
$form['field_target_select']['und']['#options'] = std_to_array($vocabulary_nudge_all);
$form['field_target_select']['#states'] = array(
  'visible' => array(
    ':input[name="field_type[und]"]' => array(
      array('value' => 'carroussel'),
      array('value' => 'vitrine'),
    ),
  ),
);

I know there would be a solution by creating several select fields with visible conditions, but later more taxonomy fields could be added.

Right now it's not even doing the AJAX call anymore, and I can't manage to fix this, so any help would be appreciated.


texts: How to add a menu link to a menu programmatically?

texts:
I want to add a menu link to a menu programmatically. Here is my code

MenuLinkContent::create([
      'title' => 'Example link',
      'link' => ['uri' => 'internal:/node'],
      'menu_name' => 'main',
    ])->save();

But it gives me the following error

PHP Fatal error:  Call to a member function get() on a non-object in /var/www/drupal8/core/modules/menu_link_content/src/Plugin/Menu/MenuLinkContent.php on line 105

Is there any way to add menu links to a menu programmatically?


texts:
I'm trying to build a module to create a custom admin page to manage a custom block. I would like to include the block content field and a checkbox to enable or disable the block.

Is this possible or should I just build a block that prints the body value from a basic page? So for example, I could just build a page and my module would enable the block depending on whether or not the page is published. So a user could edit the copy and then publish the page when he/she needs the block to appear.


texts: Views -> add relationships: why can't I find Taxonomy term:parent?

texts:
I am trying build a list of children taxonomy terms, and I don't understand why I can't find this Taxonomy term:parent in the Views UI relationships section.

Any hint is welcome

Drupal 7, Views 3

EDIT:
I was finally able to add the Taxonomy term: parent term relationship by adding first the content: taxonomy terms on node relationship.
Now I am trying to have unique results: for now the view displays one term for each node which cause duplicates.


texts: View displays nodes that should be excluded by filter

texts:
I'm working on the website for my bicycle shop. I've created a series of views that display the different types of bicycles we have: touring bikes, city bikes, etc. There is also a view that displays all the bikes.

In order to hide display of bikes that have been sold already (i.e. have 0 stock), I have the following filter criteria:

Stock: Level (>0) OR
Stock: Active (No)

(There is the provision that if the stock level is not set to active it's ok for the stock to be zero, because there are some products that we don't track the stock of).

When someone buys a bike, the stock is decreased by 1 (to 0, most often), and the bike should then disappear from the view.

Except that it doesn't.

Eg. The first bike on this page - if you click on it, it says it's sold, and the stock is set to active, and the stock number is zero.

My question is: why does it still appear in the view? I have cleared the caches, re-created the view... If I create a new view that has no filters except the criteria "Stock level > 0", the aforementioned bicycle with stock=0 still appears!

Please tell me what I'm doing wrong.

Cheers,
Chris


texts: The correct and optimal way to check language and print field depending on language, without affecting performance

texts:
I have a multilingual site, and for many reasons (don't ask why) I'm not using the Entity Translation module. Instead, I have 3 separate description fields for each language, and I want to print those depending on the current language. I just wanted to ask if this is the correct and optimal way to print render those fields, and whether or not it will have major implications on site's performance?

Inside my custom node--content-type.tpl.php at the top I put:

<?php hide($content['field_description_nl']); ?>
<?php hide($content['field_description_fr']); ?>
<?php hide($content['field_description_en']); ?>

and later inside the teaser and then again inside the full node I've put:

<?php
global $language;
$lang_name = $language->language;
if($lang_name == "nl") {print render($content['field_description_nl']);}
if($lang_name == "fr") {print render($content['field_description_fr']);}
if($lang_name == "en") {print render($content['field_description_en']);}
?>

Will this work or will it dramatically slow down the site when the traffic starts pouring in?


texts: Debugging Migrate: how to print what data's mapped to a field

texts:
I have a migration module that imports data from a CSV. I've steadily been adding code to the module and fields to the CSV, and it's always worked, albeit sometimes only after some work. But now there's one profile2 profile among the many I'm importing to in which the text fields don't get any data successfully imported to them. This happens even when I just put '1' or '0' for them in the CSV. Oddly, the non-text fields in the profile2 profile import fine, even though they're later in the CSV and the module code.

My question is how I go about debugging this. I couldn't find a 'how to debug Migrate' page in the documentation or on the web. I've found Migration::displayMessage, but what can I print via this to show what data's been mapped to these fields from the CSV? I just get the abstract mapping structure without any data from my CSV when I run Migration::displayMessage('<pre>'.print_r($this, TRUE).'</pre>', 'debug');


texts:
I have tabs created using views and has contextual filter of group parent(Group ID from URL). I created a block that has a contextual filter of GID. In the block layout, I placed the block in the content region, select Group from URL to Group ID: and specify path to be shown--that is links of my tabs.

My goal is that whenever I access each tab links, the block content will be shown according to group ID from the URL.

Given example:

Group-A(GID=1)
Group-B(GID=2)
http://localhost/tab/1/dogs
http://localhost/tab/2/dogs

Problem:

My tab view with contextual filter is working but block is not showing up. How can I properly configure the block view setting to be consistent according to the GID?

See photo below for my block settings:


texts:
I don't see the second parameter $arg being use in the function.

function hook_help($path, $arg) {
  // ....
}

Why should I declare it? What is its use?


texts:
I want the user to be able to either add a new asset by using node/add or import a CSV, but on different pages. Right now both options come out on the add page.

How can I put the feed import page on a different page and not have it on the node add page?


texts:
Is it possible have version 5 & 8 of Drush installed and to use a preferred version?

I am running an ubuntu server on which I have Drush5 installed. My attempts to remove is results in the following:

sudo apt-get autoremove drush -y
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
 linux-image-extra-3.13.0-91-generic : Depends: linux-image-3.13.0-91-generic but it is not going to be installed
 linux-image-extra-3.13.0-95-generic : Depends: linux-image-3.13.0-95-generic but it is not going to be installed
 linux-image-generic : Depends: linux-image-3.13.0-95-generic but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

All attempts to deal with that issue have been unsuccessful.

So, I'm just wondering if both versions can be installed and used independently?


texts:
I've created a view called 'Browse'. I've set the 'Query Settings' to show only DISTINCT (but it doesn't work).

Background:
I have a 'Resource' content type with a field list field called 'type'. Types may include 'blog', 'book', 'web article', etc. (there are only 8 types). I have about 80 resources in this content type, each with a 'type'.

When I create my view with DISTINCT set and content type=resource and 'type' as the only field it displays about 15 instances of each type, so it ends up looking something like this:

Blog
Blog
Blog
...
Book
Book
Book
Book
...
Web Article
Web Article
etc.

I only want each 'type' to display once and link to the views I've already setup that show all the resource content types with that particular type set (ie. if a user clicks 'blog', which should only appear once, it takes them to a page view listing all the blogs in the db.

Does anyone know how to ensure my View shows only distinct values for items in this field_list?


texts: How to combine two filters in search api views?

texts:
I have a search index which is indexing both content and files.
I have configured the search api views which displays the search results.
On this view, I have a filter on type which displays the content types as links using better exposed filter.
Is there any way to add another option to the same filter files but clicking on it will display files in the search results only.
Is it possible? Any custom solution hint?
I have tried the combined global filter but that only works with fields not with rendered entity.


texts: How do I modify the Scheduler date picker?

texts:
On the date picker for the Scheduler module, I would like to modify it. Specifically, I would like to make it so a content creator can set the time to be unpublished 120 days from now, rather than picking a date.
Any thoughts on how I could go about modifying Scheduler’s date picker?


texts: Create view with parent taxonomy terms only

texts:
I have a view of nodes, which are associated with a vocabulary, and it contains both child and their respective parent terms. What I want is in this view, only the parent categories will be coming. I have already tried the parent relationship but it gives me repetitive rows with each parents. I have described the problem and what i want to achieve here :

https://www.drupal.org/node/652234#comment-9422885

Help appreciated...


texts: Notify new user of account - must provide at least one recipient email address... doesn't send email

texts:
I've searched for a long time, but I can't find anything that helps.

Basically, when a user is created, I input a username, password, and email address.  Then, when I check the "notify user of new account" box and save the user, I go to a white screen with plain text saying: "Invalid address: You must provide at least one recipient email address." I checked the logs and the email doesn't have a "to" address.

Also, when I do login (or masquerade) with the new user, the site has a prompt stating that I need to provide a valid email because there isn't one for that user, despite a valid email address having been input at the time of creation.  When I enter the email address in this prompt, then it is saved to that user (meaning I go to the edit tab of a user and see the email address there).

Everything I've come across says it could be one module or the other... but I don't have any of those modules referenced.

I have SMTP authentication support.
I have Simple Mail.

I am able to send out test emails and other mails (i.e. from a triggered action), but not to notify users of a new account.

I'm sorry if this has been covered elsewhere... I've looked but haven't found anything that works.

Also- I'm working with Drupal 6.

It's similar to this issue: to email address not populated

Thanks.


texts: How can I populate multiple blocks on a paginated page?

texts:
my problem seemed simple to solve and how to do it.
But the paging did not work properly ..

As we see in the images, we have:

Main block with an image and description. It only shows 1 element.
Sequential block, an image and a description that the second content must show. It only shows 1 element. It is a block that is attached to the first
Third block with image and description showing the third content. It only shows 1 element. It is a block that is attached to the first
And at the end of a list of 3 cards, showing image and description. It must be shown from the third image onwards. It is a block that is attached to the first

It is content similar to news, the idea is to show different types of blocks for each content. And then paginate all the contents.
The problem I found is that when you attach elements or when doing so with blocks you can only page one block.
For example, when paging the main block, I will paginate all the attached blocks of an element. On the other hand, if I use the block of 3 cards, and I paginate it for this, I will paginate all the attached blocks with three elements.

The idea of mockups, would paginate the whole set with its corresponding content. That is, for the first page I have 6 elements shown in different ways, for the second page should show 6 to 12, the third 6 to 18. And to be more specific the main block will have the content 1 of page 1, the element 7 on page 2, and item 13 on page 3 and so on.

Example complete:

I hope you understand


texts:
I have this code

<?php
      $node = (object) array(

        'title' => 'Title',

        'body' => array(

          LANGUAGE_NONE => array(

            0 => array(

              'value' => 'Body Text',

              'summary' => 'Summary',

              'format' => 'filtered_html',
            )
          ),
        ),

        'type' => 'article',
        'language' => LANGUAGE_NONE,

        'uid' => 1,
      );

      node_object_prepare($node);

      $filepath = drupal_realpath('http://ppcdn.500px.org/52335278/cbc55dab399a4bd9caf7a27e9bb3564bc8458f65/3.jpg');

      $file = (object) array(
        'uid' => 1,
        'uri' => $filepath,
        'filemime' => file_get_mimetype($filepath),
        'status' => 1,
      );

      $file = file_copy($file, 'public://');

      $node->field_image[LANGUAGE_NONE][0] = (array)$file;

      node_save((object) $node);

      $path['alias'] = 'our-great-dsk-node';
      $path['source'] = 'node/' . $node->nid;
      $path['language'] = LANGUAGE_NONE;
      path_save($path);

      cache_clear_all();
    ?>

But can't understand where to use this code to create nodes programmatically in drupal 7 or how to use this code? To test i saved this as custom-posts.php in drupal root directory to see if this code works or not, but it gives a lot errors, so what to include?


texts: CCK Content fields cannot be added to existing views

texts:
I have used CCK to create a number of content types and content fields. I have lots of views which use these fields. Something appears to have gone horribly wrong - when I try to edit an existing view and click 'add field' I can only choose from default content fields such as 'Content: Title', 'Content: Type', 'Content: Post date' - now none of the fields I created with CCK are available in the list.

If I create a new view and try to add a field, all of the fields (including the fields I created with CCK) are available. Creating a clone of an existing view makes all the fields available when the clone is first created, but coming back to edit it later, it becomes like the existing views and only default fields are available.

In addition, if I try to add a 'no results behavior' in an existing view I get the message 'There are no no results behavior available to add.' If I ignore this and click the 'Add and configure no results behavior' button anyway. I get a white screen with an error message beginning:

[{"command":"settings","settings":{"basePath":"\/","pathPrefix":"","ajaxPageState":{"theme":"seven","theme_token":"kNuAuwAyruWbQMh31fVXVzkCihNcVzsLPyzAmLGHDNc"},"beautytips":{"beautytips":{"fill":"#F7F7F7","padding":8,"strokeStyle":"#B7B7B7","cornerRadius":0,"cssStyles":{"fontFamily":"\u0026quot;lucida grande\u0026quot;,tahoma,verdana,arial,sans-serif","fontSize":"11px"},"cssSelect":"beautytips","list":["fill","padding","strokeStyle","cornerRadius","cssStyles"]},".beautytips": ...trimmed for brevity...

Again if i start a new view this issue does not occur and adding a 'no results behavior' gives the usual options. The above error mentions the beauty tips module. I have tried disabling this module - doing this this means I don't see the initial beauty tips related code from the start of the white screen text, but the problem still occurs.

I am guessing that this problem may be quite involved, so I would really appreciate some advice on where/how to start investigating the problem. Please let me know if there is additional information I can provide that would be helpful.

UPDATE: Other users are reporting similar issues in this thread. An unsophisticated work-around is turning off views cacheing. See the link above for the limitations and disadvantages of doing this.


texts: How do Pressflow Drupal sites handle user Cookies?

texts:
Is this something handled by Drupal? What PHP, Apache, Varnish settings affect cookies?

Additionally, what's the difference in cookie handling between plain-vanilla Drupal and Pressflow?

I was seeing that in drupal_session_commit() boostrap.inc calls session_destroy():

  session_destroy() destroys all of the data associated with the current session. It does not unset any of the global variables associated with the session, or unset the session cookie. To use the session variables again, session_start() has to be called.

  In order to kill the session altogether, like to log the user out, the session ID must also be unset. If a cookie is used to propagate the session ID (default behavior), then the session cookie must be deleted. setcookie() may be used for that.

Apparently in Pressflow drupal_session_commit() gets called on every page like this:

// Perform end-of-request tasks on every page.
drupal_page_footer(), common.inc
    // Write the session, and open one if needed.
    drupal_session_commit(), bootstrap.inc
        // If our user is anonymous, Pressflow "Destroys empty anonymous sessions"
        // Destroy all data registered to a session
        session_destroy();
            // Called by PHP session handling with the PHP session ID to end a user's session.
            sess_destroy_sid($sid), session.inc

What implications, if any, does this have for user tracking in software like Omniture and Google Analytics?

See related post to cookies here: https://stackoverflow.com/questions/871283/how-do-tracking-cookies-work

Link to Pressflow documentation.


texts:
I'm trying, for the first time, to add a patch in composer.json, for a layout builder issue (https://www.drupal.org/project/drupal/issues/3045171#comment-13450756).

It's the first time I do it, I see that after using the patch composer creates a "b" directory in inside the "core" directory.

The question is: when I'll upgrade the core version what should I do, if the patch will be include in the next release? Remove patch from composer.json? And what about that "b" directory?

I've added this code in the "extra" section of my composer.json and before I've installed the cweagans/composer-patches plugin, with composer:

"patches": {
  "drupal/core": {
    "#3045171-140: Forms break Layout Builder saving.": "https://www.drupal.org/files/issues/2020-02-04/layout-builder-save-issue-3045171-140.patch"
    }
  },
"enable-patching": true


texts: How to see the filenames imported by the Feeds module?

texts:
Is there any way to see the past filenames that have been imported by the Feeds module (using Drupal 7)?

I am trying to warn people if they try to import a file that has already been uploaded by Feeds.


texts: How do I add a description to the node title form field?

texts: This might sound stupid, but I can't find a way to do it. I need to add a description to the node title, just like I add a description to other fields. How can I do it?


texts: I've implemented a custom Twig filter that wraps certain character sequences with a span. The span element didn't show up in the front end until I allowed it in the text format for the field in question (via Limit allowed HTML tags...), so it seems that Twig filters are applied before text format filters. For my current use case, it seems like it would make more sense to run Twig filters after text format filters. Assuming I'm understanding this correctly, is there a reason this is the intended behavior? And if so, is there a way to change when Twig filters are applied to a field/format?


texts:
In a content type i have a field date which has a start date and end date. using views i want to put filter in such a way that it display results in a date range form now to next 3 days. In a fields i can see content:dates and in filter i can see start and end like this.

After selecting content:start date i dont know waht to do screen shot like this


texts:
I am trying to achieve something like this http://www.vooshthemes.com/gallery/jamba/ in Drupal.
Its a CV website, what confuses me is how to deal with fields.
If u visit the link i provided above u'll see Experience, Expertise,Education and Training  Category in which u can mention from which year to which year u worked where and what was you task.

My problem is how do i enable the user to add more fields just like in the Cv example page??
i will be using Drupal 7.
any suggestion will be apppreciated.


texts: How to move "description" below the "label" for a field in a form?

texts:
Can I user form_alter to move move "description" below the "label" for a field in a form?

Let´s say I want to move the "description" of the "body" field for the basic page content type.


texts: I have installed the security review module and enabled it but where to see the security flaws? There is not next page that I am being redirected to, tried google but not much help.


texts: How to bulk install modules from local machine?

texts:
Is there a way to install multiple modules at one from a local machine?

I've seen quickupdate but that is not from a local install, and relied on FTP which I cannot use.


texts: Creating a view that excludes entity referenced nodes

texts:
Say I have a Content type of Fruit. I have an Entity Reference on the User Profile to Fruit nodes. I want to create a view that shows all Fruit nodes that are NOT referenced by the Entity Reference on the current user profile.

(More details: I can create a view that includes Fruit nodes on the current user profile, by creating a view of Fruit nodes with a Relationship to the Entity Reference on the User Profile. Alternatively, by creating a View of users, filtering by current users, and then using the entity reference to show the data from the Fruit nodes. However, I haven't found a way to create a view of Fruit nodes that are NOT referenced on the current User Profile.


texts:
i want to create a new user, for this , i have done the following things.
1.Installed SMTP module through drush
2.Installed sendmail through apt-get
3.and created the new user, when i trying to create a user it shows the error as mentioned in image.
Please someone help me to get out of it.


texts: How do you render the View, Edit, Delete, and Revisions tabs in a specific location on node/page?

texts:
What is the Drupal 8 equivalent of the following code?

<?php if (!empty($tabs)): ?>
<?php print render($tabs); ?>
<?php endif; ?>

I don't want/prefer {{ content }} as there are other fields in the page which get rendered at the same position and corrupt my template.


texts:
What are the fundamentals of implementing hook_menu()?

I would like to see the basics covered in a single question, to avoid having to answer the same similar but different questions over and over.


texts: how to hide a field when adding content through node/add for a content type?

texts: I have 7 fields in a content type and the last field value, I am updating programmatically. So it should not be displayed when adding content to it. What should I do.


texts: How do I share data from a hook to a service/controller?

texts:
I'm trying to implement a shopping cart feature that requires retrieving the data (total value of cart) from a Commerce order.  The problem is that this is only possible with a hook.  But how am I supposed to pass this data from the hook to a service/controller?  I can't find any documentation on where the return value is sent from a hook and if it exists, it's certainly not placed in a very easy to access place since I've been searching for a few days now.

Trying to implement this hook:

function commerce_cart_order_load($uid = 0) {
  // Retrieve the order ID for the specified user's current shopping cart.
  $order_id = commerce_cart_order_id($uid);

  // If a valid cart order ID exists for the user, return it now.
  if (!empty($order_id)) {
    return commerce_order_load($order_id);
  }

  return FALSE;
}

This should give me an assoc array (or some other data object) of the different elements of an order.  Not sure how I can pass this around or access it anywhere.


texts: Programmatically impersonating another user without causing the currently logged-in user to log out

texts: How should a module change the value of the global $user, execute its own code, and restore the original value of $user without causing the current user to be logged out if an error happens?


texts: How do you create a CCK field that presents a node creator with a list of the website's users?

texts:
I'm trying to add a CCK field that will present a site manager with a list of instructors which are actually a sub-group of already-authenticated users with the role name of "instructor" for a "class" content type.

The list of instructors is pretty large, and I'd rather use the actual users that are already on the site to populate that field instead of just having a plain select list.

The "class" content type will have a couple other fields, like location, day of the week, and class type. The problem is figuring out how to add the instructors, who are already authenticated users to the content type via a select list of some kind. Does anyone have any ideas on how to best accomplish this? I can't find a suitable CCK field to do what I'm trying to do, and as mentioned previously, I don't want to use just a text/select list.


texts: How to reset user anonymous & user authenticated role (both currently blocked)?

texts:
Few years ago I made some changes to user roles on my drupal website but I don't know where and how :)
I wanna probably block role: anonymous user & authenticated user.
Is there any way to change it?

Also right now I can give only administrator role...

Thanks for answers


texts:
I'm using the votingapi and rate modules but I have some issues with those modules and panels.

I'm using panels to render the node view. I added content using node > Rate widget. Everything looks fine viewing the node, even if I use the rate widget in the node.

The problem comes when I refresh the page. The rating is not anymore in the widget. That's weird because the value of the rating is stored in the votingapi_vote table, even if I show the widget using views it displays the correct rating, but not with panels.

What I'm doing wrong? Thanks!


texts: How to send an eMail to registered users after they are invited using the Group module?

texts:
I use the Group module and the "Ginvite" submodule on Drupal 7.52.

The module allows you to invite people (either registered users or users without an account) to become a member of the group that the invitation is about.

This is what happens after somebody is invited:

When I write an email in "Invitations by email" and the person is not registered on my site, then the person receives an email invitation.
when I write an email in "Invitations by email" and the person is already registered on my site, then the person receives an invitation message on the user's account, as shown in this screenprint:

However, I want people who already have a user account, to receive an email notification about that invitation in addition to the invitation (message) on their user account.

How to do this?


texts: Drupal commerce get quantity per sku in hook_commerce_checkout_complete

texts:
Inside this hook I need the total products per sku. For example, user #1 buy 2 products with the sku #7, user #2 buy 5 products with the sku #10. I need to know how to get:

sku #7 -> 2
sku #10 -> 5

I was trying something like:

foreach ( $order->commerce_line_items as $line_item ) {
   $line_item_wrapper = entity_metadata_wrapper('commerce_line_item', $line_item);
   $line_item_wrapper->commerce_product->sku->value();
}

But it gives me just sku #7 and sku #10. Also, this function commerce_line_items_quantity($line_items) didn't help so much because it gave me just the total of all sku's, not individually.

This way I can award the user with some "user points" (I think is easier this way than using rules).


texts: "Page not found" when accessing a custom module

texts:
I have created the custom registration module for drupal8. I define the path on routing.yml file but when access that module on browser side I got "Page not Found" message.  Here the sample code.

custom_form.routing.yml

    custom_form.register:
path: '/custom_form/my_form'
defaults:
 _form: '\Drupal\custom_form\Form\Formsettings'
 _title: 'Registration page'
 requirements:
  _permission: 'view user registration form'

custom_form.module

error_reporting(E_ALL);
ini_set("display_errors", 1);
/**
*@file
*custom_form.module
*/
use Drupal\Core\Routing\RouteMatchInterface;
/**
* Implementation of hook_permission()
*/

function custom_form_permission() {
  return array(
    'submit custom_form' => array(
      'title' => t('Submit custom_form'),
      'description' => t('Submit the custom_form Form'),
    ),
  );
}

/**
* Implementation of hook_menu()
*/
function custom_form_menu() {
$items=array();
    $items['custom_form/my_form'] = array(
     'title'=> 'My Example Form',
     'route_name' => 'custom_form.register',
     );
    return $items;
  }


texts: Does anyone know if there is a custom field type that allows you to assign a menu inside of the field? What I would like to do is add a list menu inside of the body field. I know I could do it manually through html but I would rather add it as a menu type.


texts: user pictures not showing up in posts & comments

texts:
I am using a custom theme and it is not showing user pics in comments.

When I compared 'Appearance > Settings > Toggle display settings' of my theme with Bartik, if found that "User pictures in posts" & "User pictures in comments" is missing in my theme settings.

I don't understand what I am missing in my theme. Please suggest.


texts: Show node only to node author and author that is referenced by node

texts:
Is there a way to allow only a node author as well as an author referenced by a node reference field to view the node and comments.

Example:

A listing content type. (for posting want ads)
An Offer content type. (for making an offer for referenced listing ad)

Listing has: Title, pics, description, location, etc... as fields'
Offer has: Title, Listing Node Reference, Message, Offered price, etc... as fields

I want to hide the offer nodes (in any view mode) from everyone but admins, the offer node author and the listing node author.

Basically, creating a simple private messaging system. with nodes as messages and comments as replies to the message that only those two accounts can see as well as admins.

Any suggestions on the best way to implement this? Thank you.


texts: Using Modal Forms - Relative paths don't work

texts:
I'm using the Modal Forms module to provide Modal Login and Register Forms across my site. Unfortunately it only seems to work if I access the link from a page which is one deep from the host folder. i.e.

Localhost/drupal/myform - Works
Localhost/drupal/node/31 - Doesn't Work

The error that throws says that

/drupal/node/modal_forms/ajax/login can't be found. Which is correct because the login form is kept at:

/drupal/modal_forms/ajax/login

It's adding the relative path on the end of the current page path.

A. Has anyone come across or solved this before?

IF NOT:

B. I think the code path is being pulled from hook_menu:

function modal_forms_menu() {
    $items['modal_forms/%ctools_js/login'] = array(
      'title' => 'Log in',
      'page callback' => 'modal_forms_login',
      'page arguments' => array(1),

I tried changing the link to  a direct path (not relative), but this doesn't do anything. What should I be trying to change to get the path to either load from /drupal/ each time or become direct?


texts: How to detect modules enabled incorrectly?

texts:
If some errors occurs in the process of enabling modules (WSOD due to OOM and others), it happens that the modules are shown as enabled. But in such cases the features of those modules are broken since the enabling/installing of the modules were not completely run.

How do I detect such modules state without re-enabling every single module?

Update: Obviously logs can be disabled/cleared/lost, don't mention them please.


texts:
I've the body field as container. When I add
'#resizable' to the field with hook_form_alter(), it is not getting resizable.

function test_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
  if ($form_id == 'node_page_edit_form' || $form_id == 'node_page_form') {
    kint($form);
//      $form['body'] = [
//        '#resizable' => TRUE,
//      ];
  }
}

How can I make it resizable?