Drupal, Silex, Symfony2, Ubuntu, Website Development
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
Apache2 has changed the way you can deploy your websites under /etc/apache2/sites-available/ the hosted directive file names need to end in .conf eg, purencool.aust.dev.conf. Below are some commands need to run Apache2 web server from the command-line
To enable a website on Ubuntu.
~$ a2ensite <sitename.conf> //Creates a symlink to sites-enabled
To disable a website on Ubuntu.
~$ a2dissite <sitename.conf> //Removes the symlink to sites-enabledRead more
The more web development I do the more I use Vim and Vim buffers. Wow, once you get your head around not using the mouse and the editing keys which are more than "i" it really does speed you up. Below are some of the keys that I need to remember.
This closes the current buffer that you are in.
This moves to the next buffer.
This to goes back to last buffer.
Lists all the hidden buffers.
Deletes the character that the cursor is on.
x //in visual mode
Vim insert commands
i to insert CRTL p will search down the document for terms you want to use
i to insert CRTL n will search up the document for terms you want to useRead more
Now that Drupal 8 is starting to use Drupal components I thought that it would be in my best interest to try installing Symfony 2 and read up on its components and how they work. From the start what you find is that it does nothing even after you have created a Bundle. Yaml is completely foreign. But after going through the Symfony 2 Cook Book things started to make sense. I love the command line tools and composer wow and to see it all in OOP, sorry Drupal but it just makes so much more sense and I don't feel like I need to belt my head up against a brick wall and then jump off a cliff. Below are some points that I found interesting when installing Symfony 2.
Redirect rules in apache .htaccess are very useful. Below are some examples that allow you to achieve some simple tasks that I use on a regular basis.
Testing to see if htaccess is working?
The best thing to do in this circumstance is find or create a file called .htaccess in your root directory and add a whole lot of characters and then open your browser. Navigate to the url in the browser. Refresh the page and you will either see an error from the web server or you'll get a blank page.
I want to customise my 404 redirect page
Create a document and call it anything you like and add it into any directory you like from public_html.Read more