Changing properties of a route in Drupal 8
Problem
I want to change the title and controller of the '/user/reset/{uid}/{timestamp}/{hash}'
I want to change the title and controller of the '/user/reset/{uid}/{timestamp}/{hash}'
I want to add a link to my content page that will dynamically change/replace content on the page using AJAX.
The solution here is add a route and to write a call back that will respond accordingly. The only difference here is
So lets see how we can do this
The core_version_requirement
key specifies what versions of Drupal that the module is compatible with.
name: Example
type: module
core: 8.x
core_version_requirement: ^8 || ^9
The above example says that the module is compatible with Drupal 9 and Drupal 9. Notice that the core key is still compulsory here
After Drupal 8.8.0 we will not need the core key anymore.
I want to use the address field in a custom form which can be fulfilled with the below code
$form['address'] = [ '#type' => 'address', '#required' => TRUE, ];
This would print the following fields
Now what if we want to hide some the above fields
Message EntityMetadataWrapperException: Unknown data property field_activity_status.
Problem: There is no specific function in Drupal 8 which we can use to get all blocks assigned to a region. We used to have a function called block_get_blocks_by_region in Drupal 7 to do this
Solution : Although we don't have a specific function we have the tools in Drupal 8 s Object oriented hierarchy to do the same. Here is the code
function my_module_get_blocks_by_region($region) {
$blocks = \Drupal::entityTypeManager()
->getStorage('block')->loadByProperties([
Problem : How does hook_update_n work in Drupal.
Why we use it: We want to perform a change on a website that is already live. We cannot uninstall and re-enable the module. So we add a hook_update_n
Solution
Well Idealy its all about the naming of the hook SO it goes like this
mymodulename_update_7002
what is 7002?