Ideas on scaling your membership site
The following is a list of idea of operations you can automate as you scale your membership base:
Read more »The following is a list of idea of operations you can automate as you scale your membership base:
Read more »Last week, you learnt about extending a Twig template to make it easy to create variations of templates without duplicating code.
Read more »YAML is a data serialisation format that is both powerful and easy for us humans to read and understand. In Drupal 8 it’s used where Drupal needs a list but doesn’t need to execute PHP. One of the reasons why YAML was chosen for Drupal 8 is because it is already used in Symfony.
Read more »You build Drupal websites. You know which modules to download and configure and how to make a pretty slick website. You might be able to use Views to build up complex queries to add some fizz to sites that you build. You might be able to create various content types and image presets. You might even know the delights of Context, Panels, Rules etc. But you might be feeling like you want to go beyond downloading, installing and configuring modules. Do you seek more freedom to do what you want? Do you have problems to solve that require a finer touch than using existing modules? Or do you just want to increase your skill level?
Read more »This snippet will select Webform (Webform module) submitted data between a given date range. In this case, that date range is between 2009-06-04 and 2009-07-07.
Read more »In Drupal Views, you can wrap a field in a basic element (such as div, span, H1, H2, p, strong). But sometimes you are going to need to wrap a field in an HTML element that is not available in the list. For example, if you have an image field that and need to wrap in a <figure>
element (this is the example we will use for this tutorial). This can be pretty confusing at first, but fortunately there are a few methods available to get the job done.
Find the number of results in a view. Add this snippet to the header or footer of the view, depending on where you want the number of results to be displayed.
Read more »Searching on fields in Views is made possible by adding an exposed filter for the relevant field. You can search on multiple fields by adding multiple exposed filters. But what if you want to have one single search box searching multiple fields? This is a very common requirement.
Read more »One of the many changes in Drupal 8 is that all HTML output is rendered via a Twig template. This means that if you want to override the HTML for a given page, node, region or field, you can copy the Twig template that is being used to your theme and make your changes.
Read more »There are various ways you can add blocks to regions in pages in Drupal. You could add it in the block interface, use Panels or Context. But what if you just want to place a block directly in a Twig template?
Read more »Adding CSS classes to templates allows you to target templates or parts of the template in your CSS files.
Read more »Two weeks ago I wrote about routes and controllers in the introduction to namespaces. This week we are going to take a much closer look at routes and controllers.
Read more »You have a piece of HTML code that needs to be included in multiple Twig templates. The code will be consistent across all of them - if you need to change it, you need to change it everywhere it is used.
Read more »Using partial Twig templates is a great way to organise your frontend code because you can reuse code fragments in multiple templates. But what happens if you want to use the same partial template in multiple places and customise its content slightly?
Read more »You hit a URL and Drupal gives you a page back. Magic! But perhaps you are wondering, what is Drupal doing under the hood? You know that putting it down to magic is not going to help you to create your own custom modules.
Read more »Drupal 8 represents a major shift away from “Drupalisms” to mainstream object-orientated PHP. Experienced developers who are used to other frameworks like Symfony, should find it much easier to pick up Drupal now than they would have in Drupal 7 and previous versions. But this shift presents challenges for those of who are used to the Drupal 7 way of doing things and aren’t necessarily up to speed with all the new PHP best practices.
Read more »Acquia has announced that they will be ending the life of Mollom. As of April 2018, they will no longer support the product.
Read more »Modal dialogs are incredibly useful on websites as they allow the user to do something without having to leave the web page they are on. Drupal 8 now has a Dialog API in core, which greatly reduces the amount of code you need to write to create a modal dialog. Dialogs in Drupal 8 leverage jQuery UI.
Read more »In the previous tutorial, you learnt how to create a modal in a custom module. If you missed it, you can check it out here.
Read more »Last week we looked at creating a link that opens in a modal by adding a few attributes to the link. We are going to take this one step further this week by creating the modal in a custom module. This will give you much more flexibility over what you include in the modal.
Read more »A few weeks ago I wrote about routes and controllers in Drupal 8 and making them a route dynamic. This week we are going to look at adding a link to Drupal 8’s menu system in a custom module.
Read more »Both Drush and Console have built-in help. If you type drush
, you will get a long list of available commands. If you type drupal
, again you will get a long list of available console commands. If you can’t remember the exact command to use to do what you need, you can scroll through the long list of commands to find the one you want.
In the last tutorial in this series, Understanding routes and controllers, we looked at the two fundamental steps to programmatically define a custom page in Drupal 8. Today we are going to take this one step further and add a parameter to the route, so that it is dynamic.
Read more »Elysia Cron is an extension to Drupal’s standard cron system. With standard Drupal cron, all cron jobs are run at the same time. Elysia Cron gives much more control and allows you to set different intervals for each cron. Elysia cron does not actually run cron, instead it schedules what should be run when the standard cron is run. It does this by skipping certain cron tasks if they are setup to run less frequently than the current crontab settings. You just need to setup the normal Drupal cron to run at regular enough intervals.
Read more »Routes and menu items are a critical part of the Drupal system. Without them, users would not be able to access the content of a website or any other page. Conceptually Drupal 7 and 8 are the same: map a URL to a function that is responsible for getting and returning the content. But the way it is implemented is completely different (as is the case with most things under the hood between Drupal 7 and 8).
Read more »This is part of the series to help you transition to Drupal 8 module development by comparing it with Drupal 7. This week, we are going to look at admin forms.
Read more »Creating an admin form is often one of the first things you’ll need to do in a custom Drupal module. An admin interface enables you to make a module’s settings configurable by a site editor or administrator so they can change them on the fly.
Read more »Hi, I’m Blair Wadman. For the past decade, I’ve been on a mission to make learning career-enhancing skills in Drupal as easy as possible.
Read more »Annotations are another one of the new concepts in Drupal 8 to wrap your head around. Annotations are written as PHP code comments above a class or function and contain metadata about the function or class.
Annotations are used by other PHP projects. For example, Symfony2 uses annotations for routing rules and Doctrine uses them for ORM related meta data.
Read more »One of the key features of a Drupal module is an admin interface. An admin interface enables you to make a module’s settings configurable by a site editor or administrator so they can change them on the fly.
Read more »Drupal is full of arrays, even in Drupal 8. But when you look at an array in Drupal 8, you may be left wondering why they look different to how they looked in Drupal 7. The reason is that the Drupal code standards now recommend using short array syntax.
Read more »You have a home, section or landing page and you need to add blocks from the Views module. You can use modules like Context, Panels or the new Drupal 8 Layouts to add blocks, including View blocks. But sometimes you just want to do this programmatically in the theme without messing around with another module and all the overhead that includes.
Read more »As the Drupal market continues to rock and roll, more and more clients need “Drupal Developers”. But what exactly is a Drupal Developer? A Drupal Developer is someone who knows Drupal right? Right?!
Read more »You’ll often find yourself having to delete all content for a particular content type. You may have tested imported content via feeds and you then need to delete what you’ve imported. Or content was created that is no longer required. Manually ticking everything in the content list is fine if you have just a handful of nodes, but if you have a lot of content to delete, it can get very time consuming.
Read more »People often ask this question. Creating a template for a specific content type gives you a lot more control over the output for that content type than just using the standard node template. You can add specific markup, re-arrange the fields and other good things.
Read more »You set up a Drupal site for a client and after launch, they complain because important things are not happening. Search is not being updated. Backups aren’t being run. Boost is not being cleared. Logs are not being pruned. All these things should run automatically when cron is run (Drupal comes with the ability to run cron automatically) at specified intervals, such as every 3 hours. So when does cron actually run, if not at the specified interval?
Read more »Developing custom modules in Drupal 8 is a daunting prospect for many. Whether you’re still learning Drupal 7 module development or are more experienced, Drupal 8 represents a significant shift in the underlying architecture and the way modules are constructed.
Read more »A reader asked me: “we save the data, but where did we save it?”. He was referring to my tutorial on creating an admin form in Drupal 8.
Read more »One of the many changes in Drupal 8 is adding a block to a region. The block interface has been pretty consistent over the years, so changes to how it works can be confusing at first. You do something over and over again and then “Wait a minute! Things have moved, what do I do?!”. But never fear, the new way of adding blocks to regions is pretty straight forward once you get your head around it.
Read more »If you are used to creating Drupal 7 modules, one of the major challenges of moving to Drupal 8 is all the changes under the hood. Almost everything has changed and that can be very overwhelming. But it doesn’t have to be. One method to learn how to create Drupal 8 modules is to compare it to what you are used to in Drupal 7 module development.
Read more »With a click here, and a click there, it can be really easy to mess up a Drupal site, especially if you are fairly new to it. It doesn’t have to be you, in the hands of your manager or client, they can end up breaking the site. Setting the correct permissions will help reduce the risk of this, but sometimes people want more permission than they really should have. And when the site owner comes to you and says - “I broke all the things!” - you immediately wonder when the last backup was. Are backups even running? How do I restore from a backup! Help!
Read more »Drupal comes with its own built in cron. This means that you can add your own job to the list of jobs that are executed when the Drupal cron runs.
Read more »Drupal 8 is (almost) here and if you are a developer, it is time to start learning Drupal 8 module development. Module development in Drupal 8 represents a major shift from Drupal 7. This is the first tutorial in a series where I’ll be going through the process of learning Drupal 8 development. The module that we create in this tutorial is as simple as it can be and is aimed at helping you get a feel for the module structure.
Read more »Us developers tend to be efficiency driven - constantly on the search for productivity gains that allow us to work faster.
Read more »When you are developing a new Drupal website, you often need to populate it with dummy content. Manually added content is tedious and wastes time. Fortunately with just one Drush command, you can generate as much dummy content as you want.
Read more »Drupal 8 represents some major changes to the way we work with themes. There is now Twig, asset libraries, component based CSS, to name a few of the changes. If you are used to working with themes in Drupal 7, all these changes can be overwhelming. But it is well worth the effort - building themes in Drupal 8 is a much improved experience.
Read more »When using Sass/SCSS and working in multiple developer environments with a source control system like Git, it is very common to get conflicts with the compiled CSS files.
Read more »Github is a great service and remains the epicentre of open source code. But for a single developer paying for private repositories, its payment plans don’t make a lot of sense. This is because they charge by the number of repositories you have. I tend to have quite a few small private repos for various projects, so the cost creeps up pretty quick. I have absolutely no objection paying Github for private repos, but the pricing structure does need to be sensible.
Read more »There are many reasons why you might want to add extra validation rules to a Drupal form. This is a simple tutorial on how to add a validation function to an existing form that is generated from a module that you have not created yourself. It could be in a core or contributed module.
A form has been created by another module, but we need to add additional validation.
Read more »Every professional needs great tools. Fortunately for us freelancers, there is a tonne of tools at our disposal to make our lives easier, more productive and keep our clients happy.
Read more »Flexbox is a relatively new CSS mode that makes it a lot easier to create awesome layouts. One of the features of the Flexbox model is that elements in a single row will shrink in size as the amount of available space is reduced. For example, if you have a row of elements and you decrease the width of the browser, the elements will shrink in width as the width of the containing element reduces. This is necessary in order to keep the elements on a single row.
Read more »You can take a normal coloured image and make it gray by applying a grayscale to it by adding a few lines of CSS. This is achieved using the CSS3 filter property. A common use case for making images gray is for client logos, like I have done on my client services site.
Read more »When you first install a Drupal 7 site with a base theme, you’ll get a couple of standard templates such as html.tpl.php
, node.tpl.php
and page.tpl.php
. But often you are going to need to create a node template for a specific content type.
The Drush User’s Guide, by Juan Pablo Novillo Requena, is a fairly short technical book, at just over 120 pages. Like meetings, the shorter the better for technical books. It is easy to read, concise and well laid out. If you are new to Drupal, this book is not for you. If you build sites in Drupal but are new to Drupal development (module development), then you will find this really useful. If you are a Drupal developer who writes custom Drupal modules, you will find this book essential reading. I have used Drush for a few years and still picked up a thing or two.
Read more »To style a block, you first need a way to target it in CSS. When you inspect a block’s HTML, you will see that it has a block ID selector. You can use that to target the block in CSS. But this is not the best way to style blocks in CSS. It can very quickly become hard to maintain. There is a better way, but first, lets look at how to do with the block ID.
Read more »Drupal ships with an incredibly powerful and flexible categorisation system, called Taxonomy. However, many developers and site builders get confused when trying to decide if something should be a taxonomy term or a field in its own right.
Read more »If there is one fear that most developers experience, it is the fear of security vulnerabilities with the code you have written. Bugs are one thing, but security holes that can be used to expose user data or wreck havoc on the database are the cause of many a nightmare. One of the most common forms of attack is SQL Injection. SQL Injection involves injecting malicious commands into a query, usually via some form of user entry.
Read more »Much of the work you do when building Drupal sites revolves around enabling and configuring modules, clicking various admin forms and updating settings. These settings are stored in the database. You should make changes to Drupal sites locally first and not directly on the live site. But changes you make to your local Drupal site need to be replicated on your live site. This tutorial is a walk through of how to automate these changes by storing them in code in a Site Deployment module. No more clicking and configuring multiple times!
Read more »Keeping your Drupal site up to date has always been of critical importance to ensure it remains secure. Last month’s announcement of a SQL Injection vulnerability and subsequent announcement of automated attacks within 7 hours caused wide spread panic across much of the Drupal community.
Read more »We all know the importance of backing up the database for each Drupal site we build and maintain. But it is not uncommon for this to be put on the back burner and never actually implemented. Fortunately, it is really easy to setup with a combination of Amazon S3 and Backup and Migrate.
Read more »When you are calling a function or method that has an argument(s), you don’t always know what type (array, object, string etc) of argument to pass to the function. And if you end up passing in the wrong type, you’ll get a less than helpful error.
Read more »Site speed is one of the most critical factors when running a site. If a site takes too long to load, visitors will hit the back button and go elsewhere. Google is well aware of this, so slower sites will not rank as well as fast sites (all other things being equal).
Read more »Simple on/off checkbox fields where you want the user to select or deselect a checkbox are a common requirement. Yet it is not so obvious how to create them in Drupal.
Read more »Do you get a lot of comment spam? I do. Spam prevention services like Akismet and Mollum do a great job at stopping a lot of the spam. But what happens if a user leaves a good, on topic comment and includes a link back to their site, or another site? By default, search engines like Google will treat that link as a vote towards the target site. As far as it is concerned, you added the link. This can be bad for a couple of reasons, the main one being what is known as a bad neighbourhood. If Google does not like the target site and you link to it, you can become part of its neighbourhood. You do not want that!
Read more »Recently one of my clients had a problem with a large portion of transactional email never being seen. The emails were being directed to the recipients’ spam folders and were generally being over-looked. These were important emails regarding things like membership confirmations, invoices and event information and were critical to the experience of the members.
Read more »Changing an existing form is one of the first things that new Drupal developers will learn how to do. It is a natural extension from site building, where you might need to change one thing on a form created by a core or contributed module. One of the benefits of using the Form API to construct forms is that any module can alter any other modules form. In this tutorial, you are going to learn how to alter a Drupal form.
Read more »Updating and reverting is an essential part of managing Features on Drupal sites. After you create a Feature, if you make further configuration changes the Feature will become overridden. This means that the configuration settings that you have made in the UI are stored in the database but do not match the feature module code.
Read more »When you add new modules to your project, you may be used to enabling them in the modules page (admin/modules). This does mean that you need to remember to enable these modules on the live site (and any other site in your pipeline).
Read more »Dealing with user accounts is an essential part of Drupal development. You’ll find yourself needing to:
Read more »When using an open source product like Drupal, it is essential to ensure that you are keeping up to date with security patches. The last thing you need is an insecure Drupal site!
Read more »Drush is awesome. Having Drush commands at my finger tips saves me a lot of clicking in the Drupal admin interface and ultimately makes me more productive. If you are new to Drush, you might find the large number of commands available overwhelming and not know which ones to start with. Here are the 10 Drush commands that I use most often - the ones I use every single day when developing Drupal sites.
Read more »I recently posted my top 10 Drush commands. In the blog post comments, over email and Twitter, a bunch of people let me know their top commands and tips. This was such great feedback, I decided to write up the list as another post. Here is the top 10 Drush commands from the fine folk who contributed (in some cases, they are variations of a command that I listed in my post).
Read more »Are you sick of having to always be in the directory that your Drupal installation is in order to run Drush commands? What if you run more than one site? Changing directories all the time is a pain.
Read more »The Features module is a vital tool in the Drupal developers and site builders arsenal. It is used to export configuration that is held in the database to a Drupal module, making it easier to version control, deploy and use on other sites. Like the rest of Drupal, you can do everything in the UI but this can be time consuming. Fortunately Features comes with a set of handy Drush commands which should save you valuable time. Let’s go through them one at a time.
Read more »There is a lot of talk in the Drupal community and media about the Drupal security vulnerability that was fixed in the Oct 15th update (7.32). If you have missed the details, here is a summary:
Read more »The three most important elements of Drupal are nodes, blocks and users. Nodes and blocks are important because they are what people see. Users are important because this is how people can administer or be a member of a Drupal website.
Read more »A few weeks ago I was ready to turn off the comments on my blog. Despite having Mollom running, I was left with a non trivial amount of spam comments to manually deal with each day. It felt like a waste of my time. I love the great comments I get. But there are always people who want to ruin the party, and for the web, it is spammers.
Read more »Drupal is a complex system. As such, there are a lot of admin and config options in the admin menu. Even when you know what you are doing, navigating it can be time consuming.
Read more »Drupal’s code is split into three main areas: core, contributed and custom.
Read more »Using the Pathauto module is a quick and easy way of automatically creating meaningful URL’s. Instead of having to type in a URL path manually for each node (page, story etc) yourself, it will do it automatically based on set criteria, like the category it belongs to and the title.
Read more »Boost is an amazing Drupal module that can dramatically improve the page speed performance. This can improve the experience of visitors and help a web site cope with unexpected surges in traffic.
Read more »To revert a features module during deployment, add an update hook and call features_revert with the name of the module and the component you want to revert.
Read more »You have gone through your regular module update routine and cleared the cache. Suddenly you are presented with a PHP Fatal error, because a class can’t be found. Your Drupal site won’t load and you can’t run Drush commands. All you get is the fatal error blocking the site.
Read more »Creating a page template for a content type gives you a lot of control over the structure of the page. While Drupal will automatically pick up a node template for a content type, if you use the right naming convention, it will not for a page template. Fortunately it just takes a few lines of code and you can create a page template for any content type you choose.
Read more »Ever feel like your Drupal code is becoming a disorganised mess? Most Drupal sites contain a decent number of contributed modules. Before long, you might write your own custom modules. And then you might generate Features, which are also modules. You end up with a heck of a lot of modules! You could dump them all into the modules folder, but then how will you distinguish between what is custom and what is contributed? Sure you know what your custom modules are, but you will have to search for them through that long list of all those modules. If only they could be more organised!
Read more »There is no shortage of Drupal meetups in London. They are a great way to meet like minded people, share knowledge, make friends and find work. Here is a roundup of the main Drupal meetups in London:
Read more »Form validation is an essential part of any web system. You need to ensure that the user has added valid data and if not, show them a meaningful error message. Validation functions are normally implemented in the module where the form is defined. However, thanks to Drupal’s hook system, you can add a validation function to any Drupal form, even if you did not create the form. In this tutorial, you will learn how to add a validation function to the node article form. This is the form where you add content to the article content type and can be found here: node/add/article
Read more »In this tutorial, you will learn how to create your first Drupal module. You are going to call this module starting drupal dev.
Read more »The Drupal Features module covers a lot of our needs with automating the deployment of database settings for Drupal 7. It allows you to export configuration to code and nicely wrap it up as a module. This means you easily deploy your changes to the live site (or a staging site) without having to repeat the configuration changes. It also means you can apply the changes to a different site.
Read more »In the first part of this Drupal Features guide, you learned why Features is a vital tool for Drupal site builders and developers. We then created a new Feature, which contained a Todo list content type. In this part, you will create a View to display the todo list in a block and add the View to the Feature by recreating it. Views are not the only thing you might add to a feature module. You can add a whole range of components, such as image presets, context and strongarm (for variables) to an existing feature.
Read more »As you build Drupal sites, define content types, setup Views and image presets, you end up making a lot of configuration changes. One of the problems with Drupal (up to and including Drupal 7) is that content and configuration is all stored in the database. I’m sure you have experienced the real headache when you want to move the content types, views and various configuration changes from a development site to production site or to another site entirely. You end up repeating configuration changes again (and again).
Read more »This is the third and final part of the series on Features. In the first part, we looked at how to create a feature module. In the second part, we looked at how to add a new component to a feature and recreate it. In this part, we are going to walk through how you can change a component that is already in a feature and then either update or revert the feature.
Read more »Have you ever needed a variation of a template in a theme where each template has a lot in common? For example the main page template and frontpage template.
Read more »You can build Drupal websites with just a few tools, such as a code editor, browser and dev environment. While it is not necessary to use additional tools, tools do make your life easier and can save you a tonne of time and improve the quality of your work. So let’s take a look at the essential tools to use to develop with Drupal.
Read more »You may be used to adding validation functions for an entire form, but what if you just want to validate an individual form element? Do you really need a form wide validation function for a single field? What if you just want to check that a user submits a number in a field?
Read more »I had the privilege of attending DrupalCamp London on the weekend of March 2nd and 3rd. I wasn’t really sure what to expect but was hoping it would be like a mini DrupalCon. I was not disappointed one little bit. It was very well organised, the talks and BoFs were fantasic and there was a great atmosphere. The best bit for me was that it was more intimate than a DrupalCon and I found it easier to get chatting to a variety of people.
Read more »Last week I had the privilege of attending my first Symfony conference, Symfony Live London. I have not done any Symfony work before (apart from some video training by Knp Labs) but I am very keen to get into it. Commercially, I have been doing mostly Drupal for the last five years, and it is time to expand my horizons. Deciding on which framework to get into next was made easy with the decision to use Symfony components in Drupal 8. Learning Symfony will enhance my ability to offer top Drupal consulting as well as stand alone Symfony. Symfony components are also going to be used may other leading PHP projects, so it is quickly becoming a must have skill.
Read more »You have a container with two elements with a class of box floated inside it, both are floated left with a width of 50% of the container. The two elements will sit side by side. However, the containing div may not actually containing the floated elements inside it.
Read more »So, you have been working on a project locally and then decide you really should version control it and share it with the world. One option would be to create the repository on Github, clone it locally and then copy all the files across. But it does not have to be so messy. Here is how you add an existing project to Github without cloning it first.
Read more »PhpStorm is my favourite IDE for PHP development and is a great tool for Drupal development. Drupal hook autocomplete used to be available via 3rd party plugins with varying reliability. It is now standard with PhpStorm with the recent release of PhpStorm 7 (via the Drupal Plugin).
Read more »MAMP (Mac Apache MySQL PHP) is relatively easy to set up, but there are a few things that I had to change. Here are my notes on the changes I made.
Read more »On my current project, we create a branch at the beginning of each sprint and maintain a clean trunk. All code from the sprint is committed to the sprint branch. At the end of the sprint, we merge the sprint branch into trunk (assuming it passes QA). This is pretty much the same setup as feature branches. Here are a few notes and snippets for this type of setup.
Read more »Debugging with an IDE like Komodo (or another debugging tool) will save you a whole world of pain. It will save you through dropping in print_r all over you code and allow you to step in and out of your code as it executes with ease. The first stage, of course, is setting it up and that is the focus of this tutorial.
I use a Mac, but run a virtual machine with Linux (Ubuntu Server). I mount the files using NFS. The steps in this tutorial will work equally well if you run Linux natively. If you do not run Linux at all, you will need to adjust some of the steps.
First we need to install xdebug with the following command:
sudo pecl install xdebug
Now we need to add some code to the php.ini.
sudo nano /etc/php5/apache2/php.ini
Add the following to the bottom of the file:
[ZendModules]
zend_extension=/usr/lib/php5/20060613/xdebug.so
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=your mac's ipaddress or localhost
xdebug.remote_port=9000
You will need to check to ensure the zend_extension path is correct:
cd /usr/lib/php5
ls -la
Do you see 20060613? If not, there should be another folder with a set of numbers. Change directory into that to sure xdebug.so is there and use that folder name instead of 20060613. What you put in xdebug.remote_host will depend on whether you are running Linux in a virtual machine or not. If you are, add your Mac's IP address. If not, add localhost.
Reload apache:
sudo /etc/init.d/apache2 reload
Go to Preferences and then Debugger.
At this stage, we want to ensure that the debugger breaks on the first executable line. This is important for mapping the URI's, which we will do in a sec (required if running in a virtual machine).
Initial break behavior: Break on first executable line
Preferences -> Debugger -> Connection: Komodo should listen for debugging connections on: a specific port: 9000
In the main Komodo menu, we need to tell Komodo to listen for debug connections.
Debug -> Listen for debug connections: Select this.
Go to the page you want to debug. It would be best to go to the home page of the project you want to debug. Append the URL with: `?XDEBUG_SESSION_START=1`. This will start the debug session. You will get a dialog box stating a remote application has requested a debugger session, would you like to debug now. Click yes.
If you are running Linux in a virtual machine, you should be asked to map to the file. You need to navigate to where the actual file is. If you have mounted the files (using NFS or similar), then select local, navigate to the mounted folder and then the correct file in your virtual machine. It would be best to map the root of the project rather than individual files.
In one of the previous steps I asked you to ensure that the debugger will initially break on the first executable line. You can leave it like that if you want, but you may prefer it to only break on break points that you specify. To change it, go back to Preferences and then Debugger and change the initial break behavior to "Run to first break point".
Preferences -> Debugger: Initial break behavior: Run to first break point
Hopefully this has helped you set up debugging on Komodo using Xdebug with a virtual machine. In a future tutorial, I will walk through some examples of how to actually perform the debugging.
Read more »A client is using the Drupal node title module and, as part of an SEO review, I want to see how many duplicate meta titles there are. The following is a simple MySQL statement that I ran to get the answer:
Read more »So, you want to allow other modules to hook into your own module. You may have implemented hooks that other modules provide, but does invoking your own hook for a module seem like a dark art? It is as simple as calling one function in your module. All will be revealed shortly, but first, lets look at why you would want to invoke your own hook.
Read more »With the default PHP settings, Drush will probably get a fatal error because the PHP memory limit is too low. Thankfully, the solution is very simple.
Read more »I was fortunate enough to be part of the biggest DrupalCon so far, DrupalCon London. 1,751 Drupalistas were there, attending a total of 73 sessions, participating in code sprints, making friends and having a good time.
This was my first DrupalCon and it did not disappoint. There were some great sessions by very talented presenters and I thoroughly enjoyed them. The best aspect of DrupalCon for me was the real sense of community. Drupal is, after all, as much about the community as it is about the technology.
Group photo of the Drupalistas
The biggest highlight for me was the keynote on Thursday: Designing the Sustainable Web, by The Web Standardistas. It was a relaxed and amusing performance by Christopher Murphy and Nicklas Persson. They took us through the history of design and how design principles from early 20th Century are relevant to web design today. Particular emphasis was put on grid system and they showed us some great examples of grid implementations.
The first keynote was by Dries Buytaert, Drupal's founder and project lead. He took us through the findings of the State of Drupal survey, which contains some very interesting stats. One important trend is that a lot of bigger organisations are standardising on Drupal as a platform, especially in the media industry. In other words, rather than using many different platforms (Wordpress for blogging, phpBB for forums etc), Drupal is being used as a single platform meeting many requirements. I have worked quite a lot in the media industry and this is something I have seen as well in the last few years. Adoption is increasing in not only media, but also finance, government, high tech and academic industries. Dries described the adoption of Drupal as a global phenomena.
I thoroughly enjoyed This Code Stinks! by Larry Garfield. Larry talked about 7 common types of code smells in Drupal projects, how to detect them and how to address them. Larry was an energetic and engaging presenter who really brought the topic alive.
Node.js seems to be getting a lot of developers very excited. In a nutshell, it is server side Javascript using Google's super fast V8 engine. The Node.js and Drupal talk was a nice introduction to node.js and how and why to use it with Drupal. One of the presenters, Justin Randell, is using Node.js for the new version of the chat room module and this was used as a great example of why node.js is useful for Drupal.
At any conference, networking is even more important than the sessions. Being a platform built by a community of contributors across the globe, DrupalCon is the time when everyone gets together. There was a real sense of community and buzz around the conference. There were plenty of social events during the evenings, including a pub crawl from Tower Bridge to Southwark Bridge, Batman Live and offical party in the O2 , quiz night, curry night and pub visits in Croydon. I met some very genuine and cool people and caught up with old friends and work mates. And that is what makes Drupal great - the people you meet and get to know - the community.
DrupalCon London renewed my enthusiasm for Drupal. I will definitely be attending another DrupalCon soon - hopefully Denver or Munich!
Read more »You can not make a table row click-able using HTML alone. By click-able, I mean nesting an entire row inside an anchor tag, as follows:
Read more »This post is part of a series of posts on making changes in Drupal programmatically rather than in the Drupal interface.
Read more »In this tutorial you are going to learn how to create a new page programmatically by registering a path in a menu hook.
Read more »DrupalCon Munich was my second DrupalCon and it proved to be as good as my first. I flew into Munich on Monday night and didn’t really stop until I left on Thursday night. I should have stayed for the code sprints on the Friday, but had a holiday to get to!
Read more »Multistep forms are a great improvement to the user experience, especially if a form has a lot of fields. Rather than users having to deal with an overly long form, you can present them with a series of steps with just a few fields on each. Most multistep forms feature a back button. The problem is, when you have required fields on a particular step, and the field is not filled in, the user will get a validation error when hitting back. This is because the Drupal form is being validated and all of the necessary validation handlers are being called and validation rules processed. Receiving a validation error when simply trying to go back on a step is not a great user experience!
Read more »Drupal is a fantastically powerful content management system. But that power comes at one very significant cost, speed. A Drupal powered site may suffer from slow page loads.
Read more »Lets say you have found a bug in someone else’s contributed module. It happens! You could raise an issue in the issue queue for that module, or you could fix it yourself and contribute the fix back to the community. You are not always going to be able to fix it yourself, but if you can, you should, as this will help everyone, not just the module maintainer.
Read more »The codebase I am working on uses hierarchical select with taxonomy to make it easy for editors to tag from nested terms. Pathauto is used to create the URL alias for the content type. We need both the parent and child terms in the URL, so use this token: [save-lineage-termpath-raw].
However, a problem occurs when you add a second vocabulary for the same content type. This breaks pathauto and it can not create the URL alias. Fortunately there is another token to save the day: [save-lineage-termpath-raw:vid].
[save-lineage-termpath-raw:vid]. only has output when terms are present for the vocabulary with the specified vid.
In this case, the vocabulary that I want to use with this path is the first one, which has an ID of 1. So the token is: [save-lineage-termpath-raw:1]
At this point, alarm bells start ringing because when you save the pathauto form, you will get a validation error.
The Pattern for all Car review paths is using the following invalid tokens: [save-lineage-termpath-raw:1].
Fortunately there is a patch for this already, which you can find here: http://drupal.org/node/1137056
If you don't know how to apply a patch, follow these steps:
EDITED 10 AUG 2010: There is an alternative solution on Drupal Coder (as kindly pointed out in one of the comments). I’d recommend checking it out: http://www.drupalcoder.com/story/18-portable-sites-with-base-href-baseurl-in-drupal
Read more »Setting the display property to inline is an alternative to setting the float property to left.
li{
display: inline;
margin-right: 20px;
list-style: none;
}
Example usage - if a field is a varchar and you need to sort by a number. It will sort it alpabetically, instead of numerically. Type casting will convert it to an altenative data type.
SELECT * FROM table WHERE column = 'variable' ORDER BY CAST(id AS UNSIGNED INTEGER ) ASC
Here is an example of how to select some data from a table on one database and insert into a table of a different database. I am assuming that you are using the same mysql connection.
Read more »The MySQL Server has gone away error can happen when trying to restore a database. There are a few possible causes for this and one of the most likely is that the database is very big in size and the packet size in MySQL is not big enough.
Read more »There are times when you pay want to force links to open in a new window. It could be to open terms and conditions, adverts or external links. Please note that some believe that you should never force a link to open in a new window as that decision should be left to the user. I will not debate this here, but rather explain how to do it should the need arise.
Read more »This snippet will get the filename from the url. The filename is the last part of the URL from the last trailing slash. For example, if the URL is http://www.example.com/dir/file.html then file.html is the file name.
Read more »I have just discovered a conflict between Skype and WampServer that I thought I would share. They both use port 80 which causes the conflict. If you run Skype before running Wamp, then Apache will not run. If you go to a site on localhost, you will probably get a blank screen.
Read more »Modify an existing column to make it auto increment.
ALTER TABLE [table name] MODIFY [column] int NOT NULL AUTO_INCREMENT
Backup a database from cron. Add the following to the cron tab.
date=`/bin/date "+\%Y-\%m-\%d-\%H-\%M-\%S"` ; cd /home/[USERNAME]/public_html; mysqldump -u [DATABASE USERNAME] -p[PASSWORD] [DATABASE NAME] > /home/[USERNAME]/backups/[DATABASE NAME]backup_$date.sql ; gzip /home/[USERNAME]/backups/[DATABASE NAME]backup_$date.sql
From time to time a user may not be able to edit a Drupal node and you end up tearing your hair out trying to figure out why. Sometimes the solution is obvious, and sometimes it is not. This post will take you through some of the main reasons for the problem along with suggested solutions.
Read more »Google offers the ability for webmasters to submit guideline information to assist its robots in indexing websites. You can even instruct the Google robot to prioritise certain pages. This is called the Google Sitemap and I highly recommend taking advantage of this facility to ensure that Google is indexing all of your web pages.
Read more »If you have a live site and a stage (or dev) site, you will probably want to add any new files (such as images) from the files directory on the live site to the staging site, or vice versa.
Read more »There may be times when you want to remove a page title from a page, but leave it as the meta title. By default, Drupal will display the node title in the h1 tag. If you take a look at page.tpl.php, you will see it there. In most themes, it will look something like this:
Read more »Out of the box Drupal will display a simple Access Denied message is a user is trying to access content that they do not have permission to. This is not exactly user friendly. A better solution is to redirect the user to the login form and when the user logs in, redirect them back to the content that they want to see. There are two main ways to achieve this.
Read more »Using .htaccess is one of the best ways to redirect a URL to a new URL. Particular care needs to be taken with Drupal sites for it to work correctly.
Read more »This post is part of a series of posts on making changes in Drupal programmatically rather than in the Drupal interface.
Read more »If you are using Drupal on share hosting, you have probably experienced a white screen. You see nothing on the screen. You had might as well be skiing in a blizzard. This generally happens when PHP runs out of memory and is one of the biggest problems with shared hosting.
Read more »You can use node relativity to attach nodes to other nodes. In this case, I am using it to attach reviews to product nodes, where the reviews are nodes in their own right. I want to be able to view the reviews (children) within the product node (parent).
Read more »I recently had a problem where PHP was timing out at 60 seconds when running a Drupal site using XAMPP on Windows (yeah I know, Windows and XAMPP sucks). I tried changing my php.ini file to 240 seconds, but it made no difference, it would still time out at 60 seconds. Here are the steps I made to fix this issue.
Read more »Drupal does have some SEO holes when used straight out of the box. In this article, I will list the major flaws and how to overcome them.
Because of the way the Drupal file system works, it is possible to access the same content with different URL's. This is particular dangerous as search engines do not like duplicate content.
Solution: Use the Robots.txt file to block search engine's from indexing secondary paths to your content. See Using Robots.txt with Drupal to avoid duplicate content for more information.
By default, Drupal does not allow you to add meta tags to pages. Description and keyword meta tags are useful in SEO if used correctly.
Solution: Install the Meta Tag module. This will allow you to add description and keyword meta tags to all of your pages.
Ok, so this is not a problem confined to just Drupal system. Search engines often have trouble indexing all the pages on a website. This problem is made worse when your content is generated dynamically from a database when using a content management system like Drupal.
Solution: Install XML Sitemaps module. This will create an XML sitemap of all of your pages. You can then submit that sitemap to Google to help its crawlers index your pages. See Set up Google Sitemap in Drupal for more information.
By default, Drupal creates standard, non-descriptive URL's for each page. Each page is a node and the URL become http://www.yoursite.com/node/1. Some search engines (in particular MSN) like to have keywords in the URL.
Solution: Install the Pathauto module. This will automatically create meaningful URL's. You can base the URL's on factors like date, author, title, and category. I would recommend you use categories and titles. For example: http://yoursite.com/category/page title.
If you are using this module, then you are creating duplicate content. A user and search engine can access your content using node/1 or cat/page-title. So it is really important that you block search engine robots from indexing anything with node in the url. You can do this by adding this to your robots.txt file:
See Using Robots.txt with Drupal to avoid duplicate content for more information on preventing duplicate content.
When following the above guidelines, Drupal is very search engine friendly. You should enjoy a higher search engine ranking then most other content management systems.
Read more »The Drupal link function is a handy and easy way to create hyperlinks in your module or theme.
Read more »It is often useful to add a “edit this node” or “edit this block” if a site editor is viewing content on a page that is not the node page itself. This includings viewing content from a “view” page where the normal edit tabs are not present for nodes or blocks.
Read more »One of the core features of Drupal is the teaser functionality. This allows you to show a teaser on the home page and category pages, rather the full article. The user has to click through to the full page to see the article in full. I really like this feature as it makes it a lot easier for user to scan through a range of stories on the home page before deciding which one they want to view in detail.
Read more »This snippet should be added in a block under “block visibility”. “Show if the following PHP code returns TRUE” should be selected.
Read more »Add new user to MySQL database. First, log into the MySQL console, and then run the following command, replacing databasename, username and password.
mysql> GRANT ALL ON databasename.* TO username@localhost IDENTIFIED BY 'password';
This is the command to restore a MySQL database.
Read more »If you are running WampServer on your local machine, it can be a bit tricky to restore a MySQL database. You need to do it from the Windows command line (DOS prompt), rather then the MySQL console command line. The actual MySQL restore command is slightly different to normal and you need to make sure you are in the right directory first.
Read more »Copying an entire directory in FreeBSD (a Unix based operating system similar to Linux) is very easy.
Read more »MySQL command to count the number of entries for a group
It is often the case that a column such as the ID column on a table will auto increment. This simply means that the next insert into the table will have an ID that is one more then the previous one and therefore all ID’s will be unique.
Read more »Drupal is a great system, but one of its flaws is the existence of multiple routes to the same content. This effectively creates duplicate content. Search engines like Google do not like duplicate content and you are likely to be penalised for it.
Read more »Normal users are not like us. We know that if we leave a page before submitting a form, the data we have added will be lost. Normal users might be happily filling in a web form, get half way through, get distracted and then click on a link and lose their data. Ok, maybe they are exactly like us, because I have done this as well. We are all busy. We all get distracted.
Read more »Lets assume that you have a bunch of nodes for a content type and you want to tag them all with the same taxonomy term. First, find the term ID of the relevant term. In example, the term ID is 103 and the content type is “contact”.
Read more »Should I use a .biz or .info domain? is a common question when trying to decide on a new domain name. Most people agree that .com’s are the daddy’s of domain names. If your target market is within one country, then you might go for a country specific domain name like .co.uk (UK), .de (Germany), .co.nz (New Zealand) or .com.au (Australia). If you really want an international domain and the .com is not available, you might try a .net or even a .org. But what if none of those are available, but .biz or .info is? Are they too obscure for your new web venture?
Read more »Use this snippet to find the URL alias for a node by looking it up in the url_alias table by its node ID.
Read more »