PHP

PHP: XDebug in VS Code

XDebug is a helpful tool when debugging code. XDebug is a step debugging tools that helps you inspect functionality of PHP code in a cleaner way than regularly writing dump/log statements.

I will not get into details here about setting up XDebug on a server, but you can find that with some Internet searching. Instead, this post is about how to use XDebug within .

Continue Reading PHP: XDebug in VS Code

GitLab DevOps: PHP Lint

Here’s another piece in a GitLab DevOps setting: when code is committed to , I want to run a linter on the custom code folders of Drupal (modules and themes) to make sure there aren’t any glaring syntax bugs that snuck through. My personal favourite error is when a “:wq” gets inserted into a file trying to exit vim, after doing all the testing.

Continue Reading GitLab DevOps: PHP Lint

Drupal: Assign Permissions Based on Username File

Here’s a recent scenario I encountered: a Drupal role needs to be assigned to certain users. The site is using a single sign on (SSO) system with a lot of users who could log in. But only some of those should be granted a certain permission. The list of those who can access the special permission role is automatically generated and put in place on the server on a daily basis, in a simple format with one line for each account name.

I have pulled out a generic version of this code and made it available on my GitHub.

Continue Reading Drupal: Assign Permissions Based on Username File

Drupal GitPod Container 1: .Dockerfile

GitPod is a great tool for cloud-based containers when developing. If you’re developing and want a safe and efficient cloud container to try things out, it’s a pretty good way to go. You even get 50 hours per month for free, which is pretty great if you only need occasional side project and not full-time work. It also works with Visual Studio Code – although that has not been working for me lately – so you can use it in the browser or in your desktop editor. When you browse to a or repository with the extension installed, there’s a simple button that will launch the container with that repository’s code, making it quick and easy to see how it works as well as make changes.

In this mini-series I describe how I created a generic Drupal-friendly container working with . It is available in my GitHub. Note that since is some code I may continue using over time, the code there may change beyond what is covered in this article.

Continue Reading Drupal GitPod Container 1: .Dockerfile

Drupal 7: Hide Label on Node Display

I ran into a problem on an old Drupal 7 site where labels for a custom field were displaying, even when there was no content associated with that field, creating a page that was simply a series of headers in a row. That’s not very user-friendly.

If I wanted to always hide the label for a field, that’s easy enough in the default Drupal display settings for the content type. But what about this scenario where we want to show the label when there is content and hide the label when there isn’t content?

Continue Reading Drupal 7: Hide Label on Node Display

CiviCRM: Personal Campaign Pages

Have you ever taken part in a non-profit fundraising event where you get your own personal webpage that you can direct people to as a way for them to sponsor you directly in the event? Personally I am happy to participate in the Coldest Night of the Year every year, which does have this type of system (not in CiviCRM).

In the language of CiviCRM, these are Personal Campaign Pages. While CiviCRM does offer this functionality, it has some major holes in it. Like a few areas of CiviCRM, it feels like somebody threw it together quickly and then mostly forgot about it. Consequently, I had a hard time ever recommending it as a good solution, even if a client was already heavily using CiviCRM happily. Here’s the official documentation.

Continue Reading CiviCRM: Personal Campaign Pages