Purencools Blog

You are here

In Drupal 8 views an anonymous user has the ability to filter content. When exposes the filters is enabled. But there is no html5 placeholder by default for a text field. The function below will add placeholder text to every views exposed form input as long it has a label.

If site builder needs to create a custom view twig file. In Drupal 8 you have to register a suggestion with the theme array. Adding the function below to your template.theme will give the developer the ability to add a twig file called views-view-viewname--.html.twig.

To create a custom twig template for a certain form in Drupal 8 you will need to add a theme suggestion hook in your .theme file like the suggestion below.

 * Implements hook_theme_suggestions_HOOK() for contact form suggestion.
function themename_theme_suggestions_form_alter(array &$suggestions, array $variables) {
    $suggestions[] = 'form__' . $variables['element']['#form_id'];

Moving production database and files from AWS Drupal 8 instance to development server using SSH is really easy on EC2. The scripts below takes a copy of the production servers files directory and database in Drupal 8, the assest are then placed all into sync directory. Then SSH copies all these files to the development server. The process below allow no user to access production using Drush

This function in Drupal 8 allows you to test the user's current role and give them access to some sort of data programmatically. For example, you might have a custom block that you want only a certain role to see. This function below will give you that functionality. Add the code to your .module file in your module .theme in your custom theme.

My ./bashrc shorthand vagrant function call for the Linux terminal. So I can speed up access to my development machines

alias www='cd /home/www/Html/'

function vup() {
    www && cd $1 && vagrant up

function vhalt() {
    www && cd $1 && vagrant halt

function vdir() {
    www && cd $1

function vdirw() {
    www && cd $1 && cd docroot

function vssh() {
    www && cd $1 && vagrant up && vagrant ssh

Auto generated passwords

function pwdg(){
   openssl rand -base64 16 | colrm $1

Beetbox is an amazing for developing all sorts of websites. But installing it on an Ubuntu host at times there can be some small issues.

Extra vagrant packages

Make sure you provision the vagrant machine after adding the plugins as you can get the dreaded "No host IP was given to the Vagrant core NFS helper" (see issue here)

vagrant plugin install vagrant-vbguest
vagrant plugin install vagrant-faster
vagrant plugin install vagrant-hostsupdater
vagrant plugin install vagrant-auto_network

Here is a list of commands the help managed your Linux machine from day to day

Find and kill a linux process from the command line

Need to remove a software process that will not go away. You might need to do it more that once,

ps aux | grep <programs name(eg firefox)> | awk 'NR==1 {print $2}'
kill -9 <number that was printed>

Setup your public ssh key so you can auto login into a server

So pipes your local public ~/.ssh/id_rsa.pub and It copies the public key to the remote server 

The Linux terminator is a multi-paneled terminal tool that as some get tricks to speed up your everyday processes while working. As a Web Developer and DevOps administrator, this tool helps from clearing a websites cache to setting up of a server and even using vim as an IDE.  Here are some commands and tips that will help you get best out of the terminator.

1. Grouping (or synchronizing) the terminal commands

When you have multiple terminals open and you need to them to have all the same command the following  keybinding will do this.

Super+G – Group All
Super+Shift+G – Ungroup All
Super+T – Group Tab
Super+Shift+T – Ungroup Tab

This bash function can find a file in a child directory and change directory to the file it is once found.

function cdf() {

    FILECOUNT=$(find  .  -name $THEFILE | wc -l)

   if [[ $FILECOUNT -gt 0 ]]; then
       CHANGEPATH=$(find . -name $THEFILE  -printf '%h\n');
        echo "Warning file was found $CHANGEPATH";
        cd  $CHANGEPATH;  
          echo "Warning: $THEFILE was not found"
alias cdf=cdf