07-26-2023, 10:27 PM
I've created a custom block like this:
class HelloBlock extends BlockBase implements BlockPluginInterface{
/**
* {@inheritdoc}
*/
public function build() {
$config = $this->getConfiguration();
$result = db_query('SELECT * FROM {test}');
return array(
'#theme' => 'world',
'#test' => $result
);
}
}
And I now want to programmatically get some parameter from the URL.
For example:
If the URL is `http://localhost/drup/hello/5569` I want to get hold of the value `5569` inside my module.
I have tried `arg(1)` and `drupal_get_query_parameters()` but I got this error messages:
Call to undefined function `Drupal\hello\Plugin\Block\arg()`
and
Call to undefined function `Drupal\hello\Plugin\Block\drupal_get_query_parameters()`
How can I get the parameters?
class HelloBlock extends BlockBase implements BlockPluginInterface{
/**
* {@inheritdoc}
*/
public function build() {
$config = $this->getConfiguration();
$result = db_query('SELECT * FROM {test}');
return array(
'#theme' => 'world',
'#test' => $result
);
}
}
And I now want to programmatically get some parameter from the URL.
For example:
If the URL is `http://localhost/drup/hello/5569` I want to get hold of the value `5569` inside my module.
I have tried `arg(1)` and `drupal_get_query_parameters()` but I got this error messages:
Call to undefined function `Drupal\hello\Plugin\Block\arg()`
and
Call to undefined function `Drupal\hello\Plugin\Block\drupal_get_query_parameters()`
How can I get the parameters?