I took the Acquia Back End Specialist - Drupal 9 Certification exam a few days back and passed it with 80% correct answers. Writing this blog post to share about my experience and preparation tips for anyone who is planning to appear for the certification exam.
Feeds is a very useful module for importing data in Drupal from various sources such as CSV, XML, etc. It integrates quite well with most of the fields and you don't have to write any code for importing data in most of the cases, but sometimes you are using a field in your content type which isn't supported by the feeds module. You can write a custom feeds 'Target' for that field in the following way and make sure it can be set as a target value:
Svelte is a very popular JS framework for developing exciting front-end applications. It can be used to create standalone apps as well as embed JS apps into your existing website. Here is how you can include a Svelte app on your Drupal website.
- Add your Svelte app folder to the module/theme folder.
- Declare the svelte JS and CSS in your libraries.yml file
- Attach the markup and library inside the render array.
DDev is a very nice Docker-based local development tool preferred by many developers especially those using Apple M1 laptops. Setting up a Drupal website is pretty easy and straightforward but using Apache Solr requires users to perform a few additional steps:
1. Based on the documentation here, follow all the steps mentioned under the installation section.
2. Place the following snippet in your settings.ddev.php file:
It is very easy to start building a Drupal 9 website in your local once you have got a few things right. Since composer is a recommended way to use Drupal, I have mentioned instructions for a composer-based setup. Here are the steps along with relevant links to help you quickly set things up.
1. Install MAMP or MAMP Pro in your system (https://www.mamp.info/en/mac/)
2. Install composer and command-line PHP in your system. (https://getcomposer.org/download/, https://www.php.net/manual/en/install.macosx.php). You can also use the MAMP provided PHP in your CLI by checking the following link https://www.choosepizzi.net/mamp-lets-make-terminal-use-mamps-php-instead-of-macs-version/.
3. Download the zip file of the latest release from this page https://github.com/drupal/recommended-project/tags.
4. Extract the content of the zip file to a folder let's say Drupal9 and place that folder in this directory /Applications/MAMP/htdocs/.
5. Go to the terminal and change your directory to '/Applications/MAMP/htdocs/' and run command composer install. This will download the latest code as well as all the dependencies. The codebase fro Drupal is placed in the 'web' directory.
6. Configure the VHost settings as per this blog post https://medium.com/@wilbo/adding-a-virtual-host-in-mamp-for-mac-a6c717cc0475. Make sure it is configured in such a way that the 'web' folder is the root of your application.
7. Hit the configured URL from the browser and install Drupal.
It is very common to use exposer filters along with the views. By default, Drupal doesn't provide any option to sort out the values shown to a user in an exposed form filter. To overcome this, enable Better Exposed filters and then you will get an option to sort the options shown in the exposed filter.
Whenever working on a multilingual website you must have noticed that views by default start showing all the translations of available nodes in separate rows. This might be a required behaviour sometimes but most of the time it is very confusing for the users and feels like content duplicacy. This can easily be solved by setting 2 additional settings in the views:
1. Add Filter -> Respective Entity (Translation Language) = Content Language Selected for the Page.
2. Rendering Language = Content Language Selected for the Page.
In case you are using relationships as well in the view (and related entities are marked translatable as well), you might have to set a translation language filter for all the entities. Feel free to set different values for these 2 options to achieve the required behaviour.
Many times, we add a hook_update_n to change the schema, perform relevant options for new releases etc. Sometimes running this function manually is required to debug it's working or re-run the logic which may not have been implemented because of failed updates. You can use Drush to run any particular function in this way:
You can configure the token in this way to achieve this:
This will ensure that tokens will return title or field_example only in the original language in which they were created.
In case you are wondering how you can update Lando in your local system, here are easy steps to do the same:
1. Go to https://github.com/lando/lando/releases/ and check if there is any new release.
2. Go under the assets column and try to find the download link of the .deb release type. Eg: https://github.com/lando/lando/releases/download/v3.1.0/lando-v3.1.0.deb
3. Open the terminal and go to the 'Downloads' directory. (cd ~/Downloads).
4. Enter wget https://github.com/lando/lando/releases/download/v3.1.0/lando-v3.1.0.deb (The link you got from the release section.)
5. Enter sudo dpkg -i lando-v3.1.0.deb (The downloaded file is passed as a parameter to the command).
6. Verify the Lando version in local by entering the command lando version.