Articles written by: George Boobyer
Apache rewrites to control access to PHP files
There are certain PHP files that you want access to but don't want to make public.
Common examples of these are:
You also don't really want to deploy these on all of your sites on a server nor have them in your git repositories for sites.
A neat way of dealing with this is to use rewriting in your web server config files (e.g. Apache, NGINX, IIS etc) to do the following:
Drupal Commerce - Best selling products
Having created a Drupal Commerce site it is likely you may need to have a mechanism to list the best sellers / a count of orders by product or similar.
Her's a quick solution that will help you.
Even if you are familiar with the structure of the commerce model this is still a complex task; linking line items, orders, products, product displays etc.
There is some background discussion here: https://drupal.org/node/1292104
Sometimes you come across a problem in SQL that is far more complex than you first imagine. One classic of these is 'Relational Division' - a poorly understood aspect of SQL that can help answer what must be a common question:
Return the things that have all of the items in a given list
Images not showing in IE8
I came across a weird situation today - that I am surprised I have not encountered (or remember encountering) before. Images that show up fine in all browsers apart from IE8 - which displays the broken image with a red cross. Came across this by chance when we were doing some cross browser testing - and of course it was a rare inconsistent issue that affects IE...
Binary logs are filling up my Mac - Help!
A colleague of mine was running out of disc space on his development machine and on inspecting the disk space usage (use - www.derlien.com) found that MySQL was using up the bulk of the disk.
Using Apache to block Spammers
Last month I wrote a post about blocking spammers from a Drupal (or any Linux / Apache) site by identifying the originating IP address from the watchdog table.
By way of an update I thought I'd share a way you can do this using the Apache configuration. Ideally this would be done in the vHosts/Httpd files if you manage your own server but works equally well within the .htaccess files that most people have access to on shared hosting.
Entity Translations and the published status flag
Always nice to start the new year with a challenge.
I created some new products for a client's Drupal Commerce site and translated them into 10 languages. All good until it was noted that the view that displays the products was showing the new products in Dutch not the default English - although all other products were showing up in the correct language.
Blocking Spam Comments
One of the housekeeping tasks that I undertake is to review the activity of comment spammers on our websites.
All of our Drupal sites use Mollom to keep us almost Spam free (big thumbs up to Mollom!)
But if you review the logs you can see that Mollom is protecting you from an alarming rate of attack and it would be good to not bother ourselves or Mollom with such traffic is possible. So the solution is to drop the traffic upstream of our web sites.
There are many ways of doing this from Firewalls to Drupal modules.
The Commerce Detective: Cloud Zoom JQuery plugin 404 errors - A solution
If you have been enjoying the Drupal Commerce Kickstart demo of what Drupal Commerce can do you are likely to be greatly inspired to use the techniques showcased in this amazing product. However you may not yet have noticed that you are getting 404 errors on the product page. In this post I cover how to solve this issue.
Drupal Translation Magic
When you create a multilingual site with Drupal there are lot of things to consider; should I use content translation, entity translation, what about views, what about node titles.
There are lot of great resources out there and with a
little lot of effort you can get it all working.
However one thing that is easily overlooked is all the strings you use in your jQuery files.
Drupal Behaviors, Ajax and doing it once
After wrestling with this for a while this evening it struck me that it isn't a very well documented area - so I thought I'd make a quick post as much for my own notes as hopefully assistance for someone else.
The issue: You have some jQuery that runs once the page has loaded and you find that it runs on Ajax post backs .. Ugh!!
The end result is that you get the behaviour repeated every time the code runs - not nice.
The answer lies in the use of the jQuery .Once() - see http://drupal.org/update/modules/6/7#jquery_once
Privacy & Cookies
Why are you looking for my crossdomain.xml?
If you are developing commerce sites and review your logs regularly, chances are you will come across 404 errors looking for crossdomain.xml. We get a lot from the plugins that looks for coupons on e-commerce sites (e.g. Drop Down Deals). In fact you are likely to get them on any sites you develop - but we have seen them more frequently on ecommerce sites.
Top Tip: Drupal Views - No valid values found on filter
Expose your Master display!
Now and again a little issue occurs that makes you pull your hair out.
I like to have NO errors on my sites and today whilst refactoring a view kept getting this error: No valid values found on filter: Content. But all my filters seem OK and the views work fine....
Doing it the Drupal way...
It is quite common practice to add head elements such as:
- metatags and links such as webfont links and
- xmlns namespaces
as text to the html.tpl.php or in template.php in hook_preprocess_html etc and other string based ways of doing things.
The problem with this is that it is hard coded and not the Drupal way. I have cobbled together some examples of how we do this in code (most of which have been gleaned from issue queues, posts and other great Drupal.org sources - credit to many anon contributors! The point here is simply to pull together some examples.
We are working on a series of Facebook modules for Drupal at the moment. These enable us to use Drupal to serve facebook applications and integrate the site(s) we are developing tightly with Facebook. We are developing them as a set of submodules (more on that later...)
Using drupal_add_js() in several modules.
Drupal Commerce for Dickies Streetwear
We were engaged to create a socially linked ecommerce site for a new brand range of Dickies clothing - Dickies Streetwear. The brief called for a high performance state of the art site that engaged a growing customer base in the streetwear market. So rather than create a run of the mill ecommerce catalogue site we wanted to create a rich user experience based around news and social media with purchasing opportunities presented across the site.
Drupal Discovery Day - Brighton
Drupal (pronounced drew-pull) is a Content Management System and web application development software written in a popular scripting language - PHP. Drupal has over 11,000 modules and over 1,000 themes, along with both a point and click interface to allow tech-savvy people to put together websites with no programming experience; and an API and framework for programmers to develop unique applications. Best of all, it's free, open source software!
Drupal Commerce Order display - Missing Template filename and path - .tpl.php
Wrestling with an error message on a Drupal Commerce site today. I kept getting errors relating to a missing template file with no path and no file name .tpl.php. Fortunatley with a little debugging giving me a pointer to the correct issue queue on Drupal the solution was readily available. So here's a few easy steps to follow in case you have the same issue.
Importing Products Displays and related Products to Drupal Commerce
In this post I am going to look at Drupal Commerce and demonstrate how to prepare e-commerce product data for import into Drupal Commerce - and show how to create a delimited list of product references to link the products to their display nodes. These techniques supplement the wealth of great practical demos and documentation provided by the Commerce team.