mediatribe.net -- Drupal and Web Development

Drupal

A hosting platform -- the end of an experiment

Last year we launched a beta version of Qumbia, a platform for creating Drupal sites easily. Today we are definitely shutting it down. I'll attempt to explain how it worked, why we're shutting it down, and what will replace it.

Here's how it worked:

  • one "master" site, with all the basic functionalities you'd want in a basic website (wysiwyg editing, captcha, blog, events, store etc.) was kept up to date.

Displaying the total number of rows in a view

Put a pager, make sure your items to display is not set to unlimited, and put this in your header or footer:

<?php
$view
= views_get_current_view();
print
$view->total_rows . ' ' . t('items in this category');
?>

Adding content (text and images) to a Drupal site via email

In my experience, there are several users who don't feel comfortable using the standard Drupal interface to create content on their website. I've noticed that this is the case with reforestation.net, I site I manage: even though I provide users with accounts and training, almost all users end up sending me their content (including images and text) via email, and I have to upload it myself to the Drupal site. The main reasons cited for not posting content to Drupal are: it's too complicated, connection too slow (especially in Africa and the Caribbean); and it does not work as expected.

Creating actions for use with views bulk operations

You can combine Views bulk operations with your own code to make powerful actions which can be applied to several nodes at the time.

Here is some sample code to create an action:


/* describe your action(s) */
function mymodule_action_info() {
return array(
'mymodule_action_callback' => array(
'type' => 'node',
'description' => t('My action description.'),
'configurable' => FALSE,
)
);
}

function mymodule_action_callback(&$node, $context) {

Displaying a block with a field from the current node using Views 2 and Drupal 6

I have a CCK field with an image on my page nodes. I want to display a block with the CCK field value on its related node, but nothing on non-pages.

This often works in the views preview, but not on the actual page. This was driving me nuts and I spent a few hours finding this solution:

Create view with

  • Filter: node nid > 0
  • Argument: node nid, Action to take if argument is not present: Provide default argument: node nid from URL; validator: basic. Action to take if does not validate: Hide view
  • Create a new block display and you're done!

Setting up wysiwyg with image upload on Drupal

Update May 3, 2010 -- Please see the first comment, below. Some of the hacks in this article are outdated. Please proceed carefully and report your results here!

Using diff and patch for directories, and managing patches during Drupal upgrades.

Background: I was recently making a Drupal site where I needed (as is often the case) a visual text editor along with image- and file-upload capabilities. I tried using the wysiwyg module in conjunction FCKEditor 2.6.x, which is a good combination for that purpose.

Since this does not work out of the box, I followed the instructions here.

Setting up Cron with Drupal 6 and cPanel

If you have a drupal site on a cPanel account, you can set up cron in cPanel. Here is how:

(1) Your site is, say, example.com
(2) Log into cPanel (example.com/cpanel)
(3) Go to cron jobs > standard
(4) Enter the following code in your cron:

/usr/bin/lynx -source http://example.com/cron.php

(replace example.com with your actual website)

Language Switcher Block: Not displaying the active language in Drupal 6

Most of our clients have bilingual (French and English) websites. The Language Switcher Block is a great way to switch between languages, but we often don't want to display the active language. For example, on a French-language page, we want to have a link to English (not French and English).

Our solution is to add the following css either to your theme, or, if you are using a contrib or core theme, to css injector. (Messing with a core or contrib theme will cause your changes to be lost during upgrades):