Drupal 8: Redirecting a form based on a field value.
I needed to redirect the user register form based on a role that the user wanted to apply for. To do this, I added a custom submit handler to the register form.
Documenting my findings about Drupal 8 here.
I needed to redirect the user register form based on a role that the user wanted to apply for. To do this, I added a custom submit handler to the register form.
I stumbled across this solution to add attributes to the read more links of a node.
Need to get out of the Drush mindset and into the Composer mindset when building new Drupal 8 projects. Some useful links that will help explain the process:
- https://www.lullabot.com/articles/goodbye-drush-make-hello-composer
- https://glamanate.com/blog/managing-your-drupal-project-composer
I was trying to theme a specific vocabulary and a specific view mode and the suggestions, by default, didn't allow for this. After some searching I came across this article, which mentioned using the hook:
hook_theme_suggestions_HOOK_alter().
So, I added the function below in my .theme file to make the following template suggestion available: 'taxonomy_term__VOCABULARY__VIEW_MODE'
I was working on a new Drupal 8 site and had a new geolocation view setup to show locations on a Google map. Everything was working well, then I decided I wanted to add a new field to the node and include that field in the view. After adding the field to the view, I decided against using it and deleted the field from the node (before removing it from the view). This, in turn, deleted the entire view, which cost me a days worth of work! I had not exported my configuration prior to adding this field, so I had no way of getting my view back without restoring my database from Time Machine.
I needed to add a 'button' class to a file field link and ran into the following issue:
https://www.drupal.org/node/2575427
I was unable to alter the actual anchor within the twig template. So, to workaround the issue, I added the following code to my .theme file.
/**
* Implements template_process_field().
/**
* Implements template_preprocess_taxonomy_term().
/**
* Implements hook_theme_suggestions_alter().
/**
* Implements template_preprocess_node().