The Date Picker widget, when using webforms, defaultly appears in American form (Month, Day, Year). For UK sites this isn't often desirable. Doing a quick google and I stumbled upon James Davidson's blog post on how to re-theme the element from earlier this year. I thought it was certainly one approach, but felt there must have been a neater alternative. So here is my approach:
It's usually considered best practice to run Drush under the same user account that the webserver runs on. Some modules, such as XML Sitemap, Advanced Aggregator and cTools, often try to alter or generate files. If you run Drush under your own account then these files may get generated as you (and therefore become unwritable by the webserver) or, if the files were generated by the webserver, are usually unwritable by your user which can mean you get errors and being unable to delete/unlink files.
The solution is to run Drush as your webuser, usually Apache. For example:
New Relic is a great bit of kit - nobody can deny that. I recently needed to configure it on a standalone box so it could be open on a large screen so my colleagues and I could see the current status of our sites. New Relic has a Kiosk Mode which strips out some of the navigation from the page an optimises it for "viewing only". Very handy.
Have you ever needed or wanted to pull a remote Git Repository on Drupal.org down as a zip or tarball? You know, the way Github does? Most project releases have fairly recently built tarballs which is awesome - but Sandboxes do not (so it seems - please correct me if I'm wrong!).
The following snippet lets you "archive" a remote repository, pull it down as a tarball, and extract it in-place:
git archive --format=tar --prefix=PROJECT/ --remote=USERNAME@git.drupal.org:sandbox/USERNAME/123456789.git BRANCH | tar -xf -
According to the Drupal Coding Standards for Documenting Hook Implementations, its considered a good practice to quickly chuck a comment before any function which implements a Drupal hook (eg,
hook_menu). This helps someone reading your code quickly see that the function is actually linked with a hook in Drupal and isn't just a function in your module to be called directly.
Ever needed to build a list which "sub-selects", say, 5 items from a given list of categories? This snippet should help.
Assume the following schema…
I've had several people ask me recently how I managed to get the nice date effect on my blog headers. It's quite simple really. All you need is:
- An Image - A background image (a CSS Sprite) which contains the days, months and years.
- Some HTML - A VERY basic HTML template.
- Some CSS - To align the image sections.
- A PHP Snippet - A Drupal preprocess function.
Isn't it a pain when you have dozens of Views setup and they are all marked as "overridden" because you just pulled in an updated feature file from somewhere. Features doesn't always notice when the Views on your site aren't up to date.
The following snippet (which you should use with caution) will batch "delete" (or Revert, once the view is in code) all Views which are marked as Overridden. This took a few seconds to run on our development machine.
So, Drupal 7 is out. Have you heard? It was a bit of a quiet launch really. ;-)
When it came to upgrading by blog, I decided (eventually) that I needed to do a cleanup as the Database had been upgraded from 4.7, to 5 and then to 6 - with many modules added and removed in between. New year, new drupal, new blog (kinda)!
It's also a good excuse to test out that some of the modules I maintain actually work in Drupal 7 (such as Page Title and GlobalRedirect). It's also a kick up the arse to get Relevant Content ported to Drupal 7!
Ever wondered if your Christmas Tree is really any good? Well last weekend I decided to make a website for this purpose. It's just a bit of fun really! You login using your Facebook credentials (using Facebook Connect) and can create Chrismas Tree posts by linking to Flickr or Facebook photo's. You can then vote on your favourite tree's in an "A vs B" type match. If you like the sound of this and fancy something a bit festive, please give it a go and let me know if you have any thoughts! Head over to Rate My Christmas Tree :-)
Sometimes, when you're running coder on a module, you'll get a lot of errors complaining about Windows line endings. This is because you should set your editor to use Unix Line endings to be consistent with all developers. See the Drupal Coding Standards for more details.
Below is a handy bash script which will help you batch convert many files from DOS to Unix line endings.
How do you find "all" the Drupal sites that Google knows about?
A post on drupal.org suggests Add New Comment, but that wont be entirely accurate. So far I have come up with a search that lists all sites with a User Account page on user/login:
intitle:"User account" inurl:"user/login"
I run XCache on the server that powers this site. XCache is cool. Out of the box, it allows caching of PHP compile code in memory, after all once a file is compile you shouldn't keep needing to compile it on every page load, should you?
Today I needed to quickly find out a list of node's which did not contain a certain token (one we use on PPOnline to insert adverts into articles). There were meant to be 2 of these tokens per article but we had noticed some only had one. Some didn't have any at all!
Now, this might already exist as a neat function somewhere, but I couldn't find it. So I wrote this little query to find the number of occurrences of a substring in a larger block of text.
I did look into using the SUBSTRING() and SUBSTRING_INDEX() commands, however I couldn't see a way of efficiently using them to find any number of occurrences. So I settled on the following…
A while ago we started having issues running a website. Bandwidth. Upon investigation, we saw that the majority of bandwidth was being use by image files and of those, lot was from the ImageCache folder. It was also causing a lot of excess server load by consuming Apache processes. Something needed to be done.
I recently stumbled across a handy tutorial on configuring a Drupal dictionary in Vim for autocomplete. I also remembered helping a friend out with a similar problem, Drupal syntax highlighting for Nano. I then combined the two and have a simple to follow tutorial for generating your own drupal 6 dictionary for vim autocomplete!
I just updated this server to PHP 5.3. As all my sites are Drupal 6 it seems I have a few issues ahead which mean I need to patch Drupal to stop PHP complaining about deprecated stuff…
So I headed over to the post on drupal.org which is discussing 5.3 compatibility in Drupal 6 (which I personally think SHOULD go in) to grab a patch. I applied the patch with no problems. I refreshed a page and got a white screen so I checked the logs only to see…
- 1 of 4