Drupal, Silex, Symfony2, Ubuntu, Website Development
This function allows you to access a taxonomy entity fields and get the following results. The child's parents TID, the TID, and the field's string name of the TID being requested. The results are placed into an array and custom keys can be used when being iterated over.
It works in Drupal 8 but I have access the fields using name spacing and avoided depreciated Drupal 8 functions and methods so it should be future proofed for Drupal 9Read more
If you have a block in Drupal 8 that needs to update its contents every time there is a page load then use the hook and code below.
On a Drupal 8 website we developed, it needed to swap out different menus depending on the page that was being requested. We found that Drupal was caching the block twig logic and the only way we could get the menus to swap was keep clearing the cache. To stop this from happening we added ['max-age'] = 0 to the right part of the block render array and all the caching on the block type stopped.Read more
If you have an SSH terminal session open and you can't get the host computer to talk to you don't close the terminal. Exiting an SSH terminal session once it is frozen is really easy just type the command in below and restart the SSH session
Press enter in the terminal and then "~ and ."Read more
In ubuntu 16.04 to add an online account like a Nextcloud instance got to settings -> online accounts, If you click the add button and it does will not respond then install gnome-control-center gnome-online-accounts packages via the command line. This allows you to bypass the unity online accounts created by ubuntu and use the gnome version. Below is the commands you need to open gnome online accounts.
$: gnome-control-center online-accountsRead more
For anyone who is looking to access Block Fields programmatically that were created in block content in Drupal 8, this function will achieve that and will also allow you to access the files URL created in the "block content" image field if it exists. This uses Drupals new namespacing so it should work into the future with Drupal 9
I created a block type in Drupal 8's UI (structure/block/block-content/types ) and added the fields. To access block type in hook_preprocessor_html programmatically you can use the following functionRead more
To make vim the default editor for Git or your entire operating system. Firslty make sure that vim is installed and then you can chose one of the options below.
If you want to change Git default editor only use the following
$~ git config --global core.editor "vim"
If you want to change the default editor across the whole installation use this command
$~ sudo update-alternatives --config editorRead more
I had some issues installing Compass on Ubuntu 14.04 this is what I did and the errors I came up against that gave me a large headache. I hope others can benefit from what I learnt. This assumes that you have already created a sub-theme in Omega4. I installed the following packages initially:
sudo apt-get update sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties
sudo apt-get install libgdbm-dev libncurses5-dev automake libtool bison libffi-dev
Download the Ruby Version Manager (RVM) so you can add any version you wantRead more
The more and more I use vim the quicker my productivity becomes this has allowed me streamlined my development tool chain. One of the issues over the years I kept finding myself doing is extending vims functionality to make it work like an IDE and more mouse friendly. I happen to find these videos on how to use vim from Derek Wyatt.org.
To my amazement I found that I had missed the whole point of vim. Using buffers instead of tabs and learning how to navigate and edit without using the arrow keys and a mouse has really shown me the power off vim.Read more
Regex can be so difficult but because of its ability to be so flexible it becomes necessary to use when searching a string that could have multiple variants. PHP uses the PCRE format so this could be used in other formats. Below are patterns I constantly use,
Searching for a characters with tags in a string
// String to be searched 1111<thumbnail code='1150400' />2222 // Regex pattern /<thumbnail code='.+?' \/>/ // Response <thumbnail code='1150400' />
Searching for the code in a string
// String to be searched 1111<thumbnail code='1150400' />2222 // Regex pattern () is what you will search for /<thumbnail code='(.+?)' \/>/ // Response 1150400Read more
Grep is a powerful tool but remembering the commands at times does affect your ability to be productive because you don't use it all the time and to recall them can be a headache. Below are important ones I uses at times
Searching a document for a word
~$ grep <searchterm> or <"search term"> <path/filename>Read more