There are some ways to make sure your loaded object is in fact an entity of type node. I prefer the following way. In addition I check if the entity types are correct too.
foreach (\Drupal::routeMatch()->getParameters() as $entity) { if ($entity instanceof \Drupal\Core\Entity\EntityInterface) { // here $entity is your object } }
Block access is a powerful way to show or hide content in some contexts. Instead of using contrib modules, this is very easy in small pieces of custom code. The following code prevents access to a block based on a subscription field in the user object.
The following code shows how to create a custom form in the drupal back-end and how to save custom config defined in your custom module. Powerful stuff and very flexible.
You can update custom config with a settings form you build. In a custom module *custom_mailing* add a file called *custom_mailing.routing.yml* add the following route:
$date = strtotime($importObject->created_at); // which is a date format $node->set('created', $date); // $node->save(); etc
From time to time it comes in quite handy to import configuration from other websites into yours. You site uuid is unique though, with the following snippet you get yours.
drush config-get "system.site" uuid
To set the uuid in drush:
drush cset system.site uuid 9b13adbf-0da5-4937-a731-xxxxxxxxxxx -y
A typical setup is one where you would redirect all non www and http requests to https://www.domainname.com. I prefer to keep my .htaccess file in version control also. With the following snippet, I get it the way I want it.
The following snippet will return your langcode f.e. 'en', 'nl', etc. Use the following code:
// Get current language code $language = \Drupal::languageManager()->getCurrentLanguage()->getId();
I got this issue on a project I worked on. One answer: enable BigPipe module to fix this.
In this case I created a custom entity called 'submenu'. In my custom module a used HOOK_LINK_ALTER to make the submenu (which contains a textfield) visible on hover. I used the code below to render my custom entity content: