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

THIS FORUM IS NOT FOR "What module..." or module support questions-- it's for module development and code related questions.

The module development and code questions forum is intended to aid those who are developing modules or writing code for Drupal.

Please note that this forum is also not intended for "Is there a module that does..." or "I need help with module x..." questions. It's also not a place to ask developers to write your code for you. Please respect this.

Please do not post general discussions intended to target module developers. If the question you have isn't specifically related to writing a drupal module, please post it in a more appropriate forum.

  • If you you have drupal installed already and are seeking a module that does a specific task, have a question about a specific module and what it does or if it will fit your use case, please place your questions in the Post installation forum.
  • If you have a problem or question about a specific module, you should create an issue in the module's issue queue (after checking for an existing issue first).
  • If you don't have drupal installed yet, please place your questions in the Before you start forum.

Custom composite - Default value setting

I have an Options element > Select type setup with custom options.  For this example, the custom options are different languages.  I would like the default value set for 'English' and am not sure what the YAML coding for default value should be for it.

The custom composite key for the Select type setup is 'autos_buying_a_car_language'.  The custom option/YAML coding is 'english: English'.

Thank you for your help!

New Custom Module with Schema Update

I've included a mfa.install file along with my module (mfa). After a few iterations my module now installs without errors but my two new tables are not added to the Drupal database. I uninstalled my module and reinstalled when fixing errors. Here is the contents of mfa.install: (I should not need a hook_update_N() function)

Get Drupal 10 Session outside Drupal

To get Userdata outside Drupal (old Version), I used the following PHP-Script:

//define('DRUPAL_ROOT', '/var/www/html/drupal' );
define('DRUPAL_ROOT', dirname(dirname(__DIR__)));
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

global $user;
$uname = $user->name;
$uid = $user->uid;
$urole1 = $user->roles['2'];
$urole2 = $user->roles['3'];
$urole2 = strtoupper($urole2);

The part to get Userdata in Drupal 10 I found:

How to alter search API query ?

I want to alter the search query so that if a user searches

for this they will get the results for that too I want to use a custom code for this 
I am using this hook but its not working as expected can someone help me with this I am using search view for search 

 

function hook_views_query_alter(\Drupal\views\ViewExecutable $view, \Drupal\views\Plugin\views\query\QueryPluginBase $query) {
  // Check if the view is the search view.

}

How to cache external source block contents

I figured I would better post this question here than in the post-installation forum.

Here is the use case:

Nodes have a google Maps Place ID.
I want to display the rating and reviews for each node in a block that will be shown on a node page.

The google rating should also feed into structured metatags.

google APIs slow the site down, so I want to cache the block contents and set it to refresh after pageload at regular intervals, to get the data ready for the next visitor.

Pages

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