drupal

Switching OG (drupal organic groups) view depending on node type

Sometimes you need to use a different drupal view when you're displaying different group types with Drupal's organic groups (OG) module, for example you might have a group thats mostly about files, and a group that's mostly about posting other items or something.

OG doesn't let you have different configurations for each node type (yet) so you can do this with a little hack, simply hit up the global $conf variable and replace it with what you need, and ensure this executes before OG does.

The Onion move to Django from Drupal

The Onion (running drupal 4.7 which may be the reason ;) are moving away from Drupal, as discovered here
http://www.contenthere.net/2010/03/the-onions-migration-from-drupal-to-d... and here http://www.reddit.com/r/django/comments/bhvhz/the_onion_uses_django_and_...


We wanted to post earlier why we like/use Django, but, we get pretty busy around here, so a bit late. Sorry if this is duping any existing threads.
Why

En route to drupalcon SF!

I'm currently flying from JFK airport to SF to attend DrupalCon2010! I've enrolled for the Cracking Drupal security 1 day session, and will definately be attending as much as i can with the rest of the conference! Looking forward to meeting up with a few local melbourne php/drupal guy's as well as catch on with what's happening with Drupal 7 because unfortunately I havent had any time recently to catch up with it (my most popular site is still drupal 5! but it works!)

oh and American Airlines WiFi is awesome :D

Fivestar voting.. Do you even need it? Or is it just a cool idea

I came across this article about youtube ditching its fivestar rating basically because users treat it as a binary thing, either they love it (5 stars) or hate it (0 stars) or simply dont bother voting, there are some edge cases where users DO bother voting however.

more here... http://youtube-global.blogspot.com/2009/09/five-stars-dominate-ratings.h...

beat.com.au now running Drupal

http://beat.com.au/ now running drupal http://drupal.org , a great choice for this kind of website! not huge amounts of data, but definate content structure, gig guides etc, nice theming too! seems to be based on the zen theme

Drupal buddylist2 to friendlist importer

A quick and dirty way to import buddylist (from d5) to friendlist (d6)
/**
 * Brute force import buddylist into friendlist
 * the friendlist import sucks pretty bad and emails everyone when they import
 */
function buddylist_import_to_friendlist() {
  $ret=array();
  $result = db_query("SELECT * FROM {buddylist} where received=1;");
  while($row = db_fetch_array($result)) {
    // friendlist can be two way so we need to insert twice with opposing uids so they handshake
    db    
  

Drupal friendlist module, every relationship is 4 DB rows

ouch!

mysql> select * from friendlist_statuses;
+-----+--------------+--------------+------+---------+------------+------+------------------+
| sid | requester_id | requestee_id | rtid | status  | rid_origin | rid  | last_update_time |
+-----+--------------+--------------+------+---------+------------+------+------------------+
|   7 |            1 |         5484 |    1 | TW_BOTH |        232 |  232 |       1259898195 |
|   8 |         5484 |            1 |    1 | TW_BOTH |        233 |  233 |       1259898195 |
+-----+--------------+--------------+------+---------+------------    
  

Backup your LAMP DB externally

Simple script you could drop into /etc/cron.daily/backup_db , handy for testing the exit level of mysqldump and rsync, and then rsyncing to your external server, keeps a rolling month's worth of backups.

error checked from mysqldump by testing for info in the STDERR output, and rsync tested by examining the return code ($?)


#!/bin/bash

# keeps a rolling 30 days of DB snapshots

mysqldump -uroot -pxxx mydrupal 2> /tmp/mysql-dump-fail.log |grep -v "INSERT INTO .cache"| bzip2 > /root/db_drupal-`date +%d`.sql.bz2
if [ -s /tmp/mysql-dump-fail.log ]
then

Added facebook connect widget to tshirtslayer

Added facebook connect widget to tshirtslayer, although it's not the actual integration just the javascript widget, more interesting to see if it has any impact on traffic. time will tell!

Saving Drupal CCK node, drupal_execute is a dog, use node_save instead

Interesting benchmark, saving 100 CCK nodes in a loop, nearly 5 seconds difference between drupal_execute method and going straight for node_save, i guess this indicates how much overhead is in the form handling (which is not a bad thing!)

heres the output!

time node object based insert: 0.00971524078067 each average, total 0.981767416
time node drupal_execute based insert: 0.0454754971042 each average, total 5    
  
Syndicate content