Developers and coders

Display a custom message with the Node_limitnumber module.

Last modified: November 7, 2009 - 20:06

I wanted to restrict the the number of posts a Certain Role could create. So I installed the "node_limitnumber" module.

It worked out great, except I was wanting a bit more functionality when it came to the execution of the code.

As the module is now, if a user try's to create more than their allowed the, module re-directs them to the add content page and following error message is displayed...

"You can't create more content of type !type, sorry."

Effective... But I decided to add some "snippets" to the node_limitnumber.module file for configuring conditional messages. This was my first real php programming venture.

Before.. (starting at line 152 of node_limitnumber.module,v 1.6.2.1 2009/09/22)

$result = db_query( $q, $node->type, $user->uid);
      $num = db_affected_rows();
      if ($num >= $limit) {// We have the data, now we check the limit
        $nodetypename = node_get_types('name', $node);
        drupal_set_message(t("You can't create more content of type !type, sorry.", array('!type' => $nodetypename)), 'error');
        drupal_goto('node/add');
      }
    }
  }
}

And After...

$result = db_query( $q, $node->type, $user->uid);
$num = db_affected_rows();
if ($num >= $limit) {// We have the data, now we check the limit

Ubuntu 9.10 (Karmic Koala)

Last modified: November 7, 2009 - 19:59

There is a Drupal package in Ubuntu, so Drupal install on Ubuntu is just this line
sudo apt-get install drupal6

Then - at the time of writing this post - some more steps are necessary to get Drupal running:

  1. enable the rewrite module and restart Apache:
  2. sudo a2enmod rewrite
    sudo /etc/init.d/apache2 restart

  3. change the rewrite base in /etc/drupal/6/htaccess
  4. from this one:
    # RewriteBase /drupal
    to this:
    RewriteBase /drupal6
    sudo sed -i 's/# RewriteBase \/drupal/ RewriteBase \/drupal6/' /etc/drupal/6/htaccess

  5. optional: increase PHP memory:
  6. sudo sed -i 's/memory_limit = 16M/memory_limit = 64M/' /etc/php5/apache2/php.ini

  7. open your browser and start the install process of Drupal:
  8. http://www.example.com/drupal6/install.php

Node Reference Create

Last modified: November 7, 2009 - 11:29

Overview

Node Reference Create is an enhancement to the nodereference autocomplete widget that allows users to reference non-existent nodes.

When no matching node is selected, the new nodes are automatically created allowing for a seamless and intuitive user experience that is similar to free tagging.

Usage

Field configuration

Once the module is activated, a new widget will appear in the manage fields page. Select the nodereference field, and then choose 'nodereference autocomplete with create' from the widgets list.

Known bugs and incompatibilities

Check the issue queue for more information:
http://drupal.org/project/issues/noderefcreate

Drupal for Facebook on D5

Last modified: November 7, 2009 - 00:12

This is where pages specific to the Drupal 5.x version go to die.

Stop using Drupal 5.x. Upgrade to the latest version of Drupal for Facebook. It may not be perfect, but it's much better!

Application Setup

Last modified: November 6, 2009 - 23:44

Setup the Facebook Application - Part 1, on Facebook.com

The following steps assume you have a Facebook account.
• Go to http://www.facebook.com/developers/createapp.php.
• If asked to login, use your Facebook login. If you haven’t created an application before, you will be asked to grant Facebook Application access to your Facebook account. You have to allow this in order for this process to work.
• Facebook will ask you for the Application Name that you want to use. This is a short human-readable name. It will be viewable to those who are allowed to visit your Facebook account so make it simple and clear.
• Agree to the terms and click Save Changes. Note: The next page that appears will contain three pieces of information that you will need for your Drupal FB Application: API Key, Application Secret, and Application ID. You will copy and paste this information into the applicable fields when creating your Drupal FB Application.

Canvas Page-specific Setup

Not necessary for Facebook Connect-only applications.
• Click on canvas in the left menu of your Facebook application screen. At the top of the screen that appears next, fill in the URL field. Keep the URL simple and descriptive. Formatting restrictions are provided on the screen. Please read them.

Setup the Application - Part 2, on Drupal

Prerequisites

Last modified: November 6, 2009 - 23:02

In order to install and configure Drupal for Facebook, you need to do a couple things first.

Facebook Account

You are going to need a Facebook account. If you don’t have one, go ahead and create one now.

Devel Module

This module is not required on your production site but will be helpful on your development site. The FB module comes with the DFF (Drupal for Facebook) Devel module and provides blocks and messages that help when developing and debugging Apps. If you intend on using the DFF Devel module, download the devel module and enable it. (You wont get very far without this).

PHP JSON

Facebook requires your PHP installation to have JSON extensions to be installed. As of PHP 5.2.0, the JSON extension is bundled and compiled into PHP by default.
To check which version of PHP you are using for your D6 site go to admin > reports > status reports. If you have something less than 5.2, your PHP installation might have JSON extensions already installed. Please check with your hosting service provider. Information about JSON extensions is located at http://us.php.net/manual/en/json.requirements.php. Your hosting service might need this link. If you don’t have this installed, you will not be able to push content from your site to Facebook.

Syndicate content
 
 

Drupal is a registered trademark of Dries Buytaert.