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

adding a query parameter to an url inside block

Hi,

There are two content types: Heritage Texts and Source Node

Every Heritage Text content has a link to the Source Node. The link is called inside a block.

Now in the AddBlock.php file, I have to add a query to the url (the link for the Source Node). The query paramter should be the node id if the Heritage Text content.

Please let me know how can I add the query parameter.

The $url looks like the following in the code, I have tried to add a query parameter, but I know that's not the correct way to do it. Please let me know.

Batch api not sending enough argument -> ArgumentCountError: Too few arguments

I run code similar to https://bitcookie.com/blog/importing-csv-file-drupal-programmatically-us...

The error is that batch.api does not pass enough argument to my function _csvImporter_import_line($line, $session_nid, &$context). It was working whit drupal7 on php 7.0 whitout error. Now, whit the update to PHP 7.2 on server, it does not work anymore:

Why does my page automatically go up each time the logo is refreshed ?

I have a site on Drupal 8 and I update a block view with the following code :

(function ($, Drupal) {
 
'use strict';
 
setInterval(function() {
$('.region-navigation-logo .view-display-id-block_3').trigger('RefreshView');
}, 10000);
 
})(jQuery, Drupal);

This code updates the logo of the site. The problem is that if I scroll the page down, it goes up a little automatically every 10 seconds.

You can test on my site with :

Printing the field values of node

Hi,

I am trying to print the contents of the body in the node. These are the following lines of code:

function training_module_node_insert(NodeInterface $node){
     if($node->getType() == 'text') {

        $var = $node->body->value;
        print_r($var);
       
}
}

 But nothing is getting printed. Please let me know how can I print the content of the body?

Thanks,

Regarding the buildForm()

Hi,

I have a sample code where the node is loaded in the buildForm function like the following.

public function buildForm(array $form, FormStateInterface $form_state, $node = NULL) {
     $node_info = \Drupal\node\Entity\Node::load($node);
     $form['textid'] = array(
        '#type' => 'hidden',
        '#value' => $node,
     );

My question is, the node parameter is by default set as null. Then how is the node information getting loaded? 

Thanks,

Modify SQL Query

Hi

I have a several MySql Tables in another database. Using  hook_views_data() I can make views to display the contents.

How can I modify the SQL query on the fly

For example depending on the user role a WHERE user_role="some role" clause to limit which data is displayed.

Im using Drupal 8.7.3

Many thanks

Brian

Pages

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