developer resources
Codebales holds an ever growing number of solutions to problems that we have experienced in our day to day code writing
Selected filter
187
results
Andrew Fletcher
•
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
/**
* Change the display of the user's name.
*
* @param int $uid
* User id.
*
* @return string
* User name.
*/
function change_users_name($uid) {
// status of the current user
$logged_in =...
Andrew Fletcher
•
Running a few SEO and performance tests and I discovered that the site logo...
Andrew Fletcher
•
How do you exclude the current node from a list view?
In some situations, for...
Andrew Fletcher
•
I'm receiving an error with a path of Drupal\path_alias\AliasManager
Upgrading...
Andrew Fletcher
•
Let say in composer.json you have
"drupal/core-recommended": "^9.2" You're...
Andrew Fletcher
•
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
Steps to get a custom Solr working
Install Search API Synonym
Read through the instructions on the module page or have a look at the following article
Setting up synonyms on your Drupal site with a few errors you might...
Andrew Fletcher
•
Running Docker
Dangerous word... I'm assuming that Docker is installed....
Andrew Fletcher
•
Is Docker installed?
Check if your installation is ok and spin up Docker as...
Andrew Fletcher
•
Create and push to Docker Hub
Creating your own custom image... you need to have...
Andrew Fletcher
•
If you are using theme_get_settings, such as:
$value =...
Andrew Fletcher
•
Running composer on a server... when running the command composer update, screen would error out. In the site directory, composer would show
composer --version
Composer version 1.10.24 2021-12-09 20:06:33Whereas, the commnd
/opt/plesk/php/7.4/bin/php /usr/lib64/plesk-9.0/composer.phar --version
Composer version 2.2.5 2022-01-21 17:25:52Ok, so composer on the server is running 2.2x. But on my site directory, 1.x
Updating Composer
If I ran the command to update composer...
Andrew Fletcher
•
Having access to a site’s URL in your templates can come in handy for many...
Andrew Fletcher
•
I want to create a content type that has a paragraph. Easy enough.
What...
Andrew Fletcher
•
Creating URL's in Drupal programmatically:
Internal path
use...
Andrew Fletcher
•
Working in Drupal 9.x, I was loading images via the Media module. Below 1...