Posts

Find total rows by day created with PHP and MySQL

November 13, 2017
Uncategorized

I was recently asked by a client to produce a report of content posted by day. My first instinct was to query the database for all rows of the particular content type and handle the counting in PHP. First Idea # Query the database for all rows of content type X Create an array in PHP of days Loop through all rows Use PHP to figure out the day the row was created Increment the array element for that day This seemed pretty inefficient though and felt like something some SQL could handle far better. ...

The Power of Knowledge Sharing

November 7, 2017
Uncategorized

The web is constantly developing and growing at a fast pace. I often wonder how beginners even know where to start and marvel at their ability to not be daunted by the myriad of options available to today’s developers. I started my web developing career when there was a clear distinction between HTML, CSS and JavaScript. I remember using table based layout but quickly processed to floats for layout and some simple JavaScript for things like rollovers. ...

Drupal 7 Views Sort by Two Date Fields

October 31, 2017
Web Development
Drupal

To achieve this you will need to implement hook_views_query_alter() in a custom module. I did not do this in Views UI. A recent project at Headscape required me to build view listing two different content types that would use two different date fields to sort by. For examples I’ll use the default basic page and article content types. The Problem # Some content types need to be sorted on the node created date and others on the display date field. ...

Stepping back to move forward with ReactJS

October 20, 2017
Web Development
decoupled drupal, Drupal, ReactJS

I’ve been using ReactJS as I have been exploring Headless / Decoupled Drupal and have so far found it to be very nice to work with. However, as I am not overly familar with it I’ve found myself looking up lots of things to ensure I’m doing it “the React way”. This has meant I’ve been doing more React learning than I have Drupal learning. My solution is to go back to an existing Drupal 7 project where I have a custom piece of search functionality and replicate it using JSON feeds provided by Drupal and a ReactJS frontend. ...

Headless / Decoupled Drupal 8 First Go

October 4, 2017
Uncategorized
decoupled drupal, drupal8, headless drupal

The installation of a minimal Drupal setup is very quick and easy. From there I enabled a few modules and a theme to help me create some data. Modules enabled Field UI Image Views View UI RESTful Web Services I also installed the Devel module to help with dummy content population of my content type Article. A common function of a website is to list content in an order, newest items or most relevant, and paginate this list. ...

Testing SSL certificates without a domain name

June 27, 2016
Uncategorized

Recently at Headscape we were setting up a new server ready to launch a redesign of a site. Whilst testing we were accessing the site using the server’s IP address which works fine for checking everything is working, apart from when we needed to install the SSL certificate. The SSL certificate is based on a domain name so going to an IP address causes the SSL certificate to warn of an insecure connection. ...

Drupal Commerce, TeamCity and Git Submodules

June 17, 2015
Uncategorized

At Headscape we use TeamCity as our Continuous Integration server and I recently came across an error when trying to build Drupal Commerce Kickstart. The main parts of the error message were Failed to build patch for build... due to error: 'build patch' command failed. stderr: The repository has a submodule in the commit '77b28273d1ebb08fd03ee254bbb20b6b476d16ec' at a path 'profiles/commerce_kickstart/libraries/jquery.bxslider', but has no .gitmodules configuration at the root directory To fix this I needed a list of the submodules which I found using a command given in this Stack Overflow thread ...

Enjoying getting it wrong

March 4, 2015
Web Development

This post also appears on the Headscape site as part of our blog. During my teens and twenties I spent a lot of time skateboarding. It’s quite a unique sport in the way it influences your life as a whole. For example, you begin to look at architecture in a new creative way. You also fall over, a lot. In fact you get really good at falling over: jump down ten steps roll across the concrete, hop up and do it again. ...

Boagworld article Do people see you as a roadblock

February 1, 2015
My work, Web Development

Paul Boag has recently posted an article titled “Do people see you as a roadblock?” that includes some very nice mentions about me. So in a shameless act of self promotion I’m going to link to it. You can read the article at https://boagworld.com/dev/do-people-see-you-as-a-roadblock/

Codeception Database Helper

May 15, 2014
Uncategorized

I’ve been using Codeception for some acceptance testing recently. The project has a large database and using the standard Codeception database module that rebuilds the entire DB from an SQL dump was too slow. All I needed to do was run a few queries to put some tables into a known state. I made a helper module that will run all .sql files in a directory. I’ve put the DbHelper on Github and hopefully it will be useful for others. ...