This forum is for module development and code related questions, not general module support. For general support, use the post installation forum.

Howto access a pages taxonomy from a block?

I'm new to Drupal development and created a new very basic custom module similar to what you find here .

One of my content types includes a taxonomy which allows to choose between a bunch of predefined HTML segments stored in the taxonomy description fields.

Now I would like to access this description field content of the current node from my custom block, but I have no clue how to access the proper variables.

tempStore not working for anonymous users

I've got a D8 module that depends on tempStore working for anonymous user sessons.  I'm pretty sure that we had it working earlier in the year, but recent tests show that it's not working now.  Has there been a change in D8 in the last few months (we've been keeping up with Drupal 8 updates) that would have affected the way D8 handles TempStore for anonymous users?  Is there any way to restore tempStore working for anonymous user sessions?

Drupal 8 and Form

I am trying do this. I have module with controller and form. I want render my form in specific place in twig template. Not only one template, but everywhere in my website. Earlier in Drupal 7 i easy do this with

$form = drupal_get_form('modalform_form');
 $showbody .= drupal_render($form);

But in Drupal 8 I have only empty form data. I try every manual here. But not working. For me is working only form in routes - so page defined in module.routing.yml show me form.

If I use in controller

Finding only duplicates of a field value

I am building a table view of a custom entity, and I am trying to build the view out so that the only results it displays are results that are potential duplicates (based on there being two or more rows of a specific field). I was originally using hook_query_alter() and adding a havingCondition() to it, but that doesn't work because in order to use HAVING you need to use GROUP BY which condenses all the results into one row. I want all of the rows to display, but only if there is another row with the same field value. 

As an example, if these values are in the database;

$form['#attributes'] targets element 2 parents up

I need to put a file upload form in a block in Drupal 8.7.10.  Everything was working great with my form as a standalone page but when I use the formBuilder to create a block for it, the form's submit handler stops receiving any files.

I've narrowed it down to the fact that Drupal is not adding the enctype attribute to the correct element.  It's adding it to the container div within the block, not the form element.  While testing this, I've found that all $form['#attributes'] go to that div instead of the form.

Error in extracting files from zip folder


I am trying to extract audio files from a zip file, the file seems to get uploaded but its corrupt and hence wont play. The following is my code, I am only showing the part where I am extracting the file:


Subscribe with RSS Subscribe to RSS - Module Development and Code Questions