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

What the comments tell Drupal?

Hello.

I have this code:

```

<?php

namespace Drupal\module_hero\Plugin\Block;

use Drupal\Core\Block\BlockBase;

/**
* It provides a block called "Example hero block".
* class HeroBlock extends BlockBase{
*
* @Block(
* id = "module_hero_hero"
* admin_label = @Translation("Example hero block")
* )
*/

}

Do we always need a <module>.module file to pass data from controller to template?

Hello.

I have this file HeroController.php:

```

<?php

namespace Drupal\module_hero\Controller;

use \Drupal\Core\Controller\ControllerBase;

is there a way to delete a taxonomy term without deleting its children in Drupal 8?

Hello,

Is there a way to delete a taxonomy term without its children being deleted and without going through the Taxonomy Manager contributed module (This module causes a problem when editing a term)?

Thanks !

Create pager in form not related to query.

I built a module that is used to manage data import from another rest resource.
So the main goal is to have a form with a table and users can select which rows to import.
What I need is to display form element pager and limit items per page, there is simple solution when working with Drupal entities:

$pager = $query->pager('10');

But now I need to add element '#type' => 'pager' that is not related to the database but to the rest resource instead. Any idea how to achieve this?

Create and immediatelly download a csv file

Hi everyone,

I'm trying to create a csv file from a form and then directly propose to download it.

My csv file is created, but then, nothing happends. No errors in the watchdog, dpm messages are displayed, but nothing to download...

Here is my code :

How can I retrieve current page and range details in a PagerSelectExtender

Hi,

I've got a dynamically-generated select query in my custom module. The query is working well and the results are paging with

$pager = $a_query->extend('Drupal\Core\Database\Query\PagerSelectExtender')->limit(5);
$a_result = $pager->execute();

However, on the page, I'd like to tell the user which results they are seeing out of how many total (e.g. "Viewing 15-20 of 48"). I can't figure out how to get at any of that range and total data though and finding nothing online for Drupal 9. Thanks for any assistance.

Pages

Subscribe with RSS Subscribe to RSS - Module development and code questions