Drupal: how to import the configuration on a different site
After cloning a site, next you will want to import the config file. Which you can do so by running the command:
drush cim -y
Hopefully it worked for you. As it didn't work out so well for me as the response was:
How to get the node.nid from the alias
In this instance, I'll check the beginning of the string. I want to focus on the href's that start with /node/. Which has been added using the variable $catchPhrase.
Using the Drupal service path_alias to return the node.nid as follows:
git commit tag steps
Adding git tag to your actions.
The regular process that I work to is
git add -A
git commit -m "some comment"
git push
With git tag, whilst there are many options for how you can apply git tag, this initial step I'll keep simple. As follows:
Get the current user or load a user using a uid value
How to get the current user or load a user using a uid value.
$current_user = \Drupal::currentUser();
$user = \Drupal\user\Entity\User::load($current_user->id());
or just use
$user = \Drupal\user\Entity\User::load(\Drupal::currentUser()->id());
An example of this in action
How to run an update using composer, but not to the latest version of Drupal
Let say in composer.json you have
"drupal/core-recommended": "^9.2"
You're attempting to run
composer update "drupal/core-*" --with-all-dependencies
...to update to the latest 9.2.x version. Yet instead you are finding 9.3.6 installed.
Using synonyms in Solr
Have you tried adding custom synonyms to Solr on Drupal?
How did you go?
What do you need to do to connect a custom synonym list to your Solr?
Set-up : the tools
What am I using?
Search API Synonym- https://www.drupal.org/project/search_api_synonym
Solr : 8.1
Deprecated function: trim() PHP
Updating to PHP 8.1, I found this interesting code stop...
Deprecated function: trim(): Passing null to parameter #1 ($string) of type string is deprecated in bales_preprocess() (line 162 of /var/www/{path/to/file})
What is trim(). Very simply, it removes whitespaces (if they exist) at the start or end of a string.
Mariadb hangs on start up in Docker
Running Docker and attempting to install a web proxy environment where I'm attempting to create local web set up the consist of Drupal 9 with Composer + Docker-compose + Nginx + MariaDB + PHP8.1
However, when I run the command
docker-compose up
The terminal hangs at
Run Drupal 9 with Composer + Docker-compose + Nginx + MariaDB + PHP8.1
Running Docker
Dangerous word... I'm assuming that Docker is installed. Don't know how to check? Using Terminal (I prefer iTerm2), run the following command
docker -D info
The set-up
Go to your project directory, and create a docker folder and a “docker-compose.yml” file:
Set-up Docker for Drupal
Is Docker installed?
Check if your installation is ok and spin up Docker as well:
docker -D info
Using Docker
Now it's time to download and install docker images. Using the official images of MariaDB and Drupal. If you don’t specify the absolute URL to the image it will be searched and downloaded from Docker Hub. Tag 'latest' will be used by default.