Drupal 8: Add a class to the more link of a view.
/**
* Implements template_preprocess_views_view()
/**
* Implements template_preprocess_views_view()
In order to alter a menu item that is provided by a module/system, you can use hook_preprocess_menu__MENUNAME() (Since hook_menu_alter() no longer exists).
In my instance, I need to change the system provided 'Logout' link to read 'Log Out'. In order to do this I added the following to my THEMENAME.theme file:
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.
Today I needed to add a custom textfield to the 'customer information' pane in Ubercart. After much searching, I wasn't able to find any modules that would allow this to happen, so I wrote my own.
I found this article, which gave me the starting block (as it was written for Drupal 6 I believe).
We had to install a new WordPress site onto an old MySQL server and received the following error on import:
In order to fix, we needed to change the collation of the sql file. To do this easily, we found the following snippet:
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().
Not sure what happened with GlusterFS tonight. Around 19:07 EST, the AWS alarm sounded. After rebooting the GlusterFS servers and the web servers, nothing was bringing the sites back online. There was a terrible lag when accessing the GlusterFS file systems and there weren't any glaring errors in the log files.
/**
* Implements template_preprocess_node().
Adding placeholder text to a Drupal 8 form element that is the label of the form can be done in your .theme file with the hook template_preprocess_input().
Today I had the task of gathering files from a Drupal website into an archive to send to a client. The files were stored in the database and were spread out across the public files and the private files directories. In order to create an archive and prevent the client from manually clicking on 1000 file download links, I did the following.
I came across a need to keep a menu link active, but, I didn't want it to be displayed to the anonymous user. After much searching I found the hook_menu_link_alter() function and the hook_translated_menu_link_alter() function.
With these functions, I was able to alter the menu item that I wanted to not display with hook_menu_link_alter():
The SMTP module alone will not route system generated emails from Ubercart through the SMTP module. In order to accomplish this you also need the MailSystem module.
Then, you need to configure the mail system module with a new class that users Ubercart to format emails and SMTP to send the emails.
Today I had the need to dump a certain amount of rows from an existing database and insert them into a new table with the same structure. This application required me to not include the table structure nor the primary key (id). To get the database dump, I used the following command.