Canvas Page Recipes

The term Canvas Page refers to the original flavor of Facebook Application. That is, content which appears within Facebook, as opposed to a Facebook Connect application. If the URL starts with http://apps.facebook.com/..., then we're talking about a Canvas Page.

Enabling Canvas Pages

  1. Make sure the Canvas Pages module (under Drupal for Facebook) is enabled.
  2. Enable a theme which is canvas page aware. This could be an FBML flavored theme or an iframe flavored theme, depending on which style of canvas page you intend to support. Drupal for Facebook comes with a theme called fb_fbml which is a good one to start with, and supports both FBML and iframe. You may need to copy the fb_fbml/ directory from .../module/fb/themes/ to .../themes/ before enabling it!
  3. When editing your application on facebook's developer app, under Canvas you can choose a Canvas Page URL. Make sure this is selected.
  4. When configuring your Facebook Application node, look at the Facebook canvas pages fieldset. Here, you can specify whether anonymous users are permitted to view canvas page, which theme to use, and several other options.
  5. Save the Facebook Application node, then visit your Canvas Page URL. Hopefully it works!

Node Gallery Display Module Configuration

Features

Supports the Ad Gallery, Easy Slider and the Galleriffic Photo Gallery.
It gives you a Tab on the User Account Page, user/%uid/galleries.
Provides a block for random images.
Provides a user selectable display when creating a gallery
** Download node_gallery_display_2.zip from Drupal.org
There is a problem with the release page not showing the download.

Example: file.save, node.save via XML-RPC in Python

Sample code for using the Services API via XML-RPC

Includes system.connect, user.login, file.save, file.get, node.save (with file attachment and CCK text field) and node.get.

How to display sub menus (children) of primary links in Drupal

This page describes how to display sub menus (children) of primary links in Drupal.

Using Menu Block

  1. Download and install the Menu Block module.
  2. Create a new menu block.
  3. Set the value of "Starting level" to "2nd level (secondary)".

Programmatically

Step 1: Since we'll be using php codes in a block to display menu, the first thing to do is to enable the PHP Filter under modules.

Creating views programmatically in Views 2

To create a View via code with Views 2 in Drupal 6:

  1. Create the view using the View UI like you normally would
  2. Export it to get the code
  3. Replace the first line ($view = new view;) with this: $view = views_new_view();
  4. Then display it, execute it, embed it, or whatever you want (i.e. $view->execute_display('default', array())

Here is an example using a simple View that displays the Title field of all Published nodes:

<?php
//create a new view
$view = views_new_view();
//define the view (this code was generated by the Export)
$view->name = 'test_date_view';
$view->description = '';
$view->tag = '';
$view->view_php = '';
$view->base_table = 'node';
$view->is_cacheable = FALSE;
$view->api_version = 2;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->override_option('fields', array(
'title' => array(
'label' => 'Title',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,

Publishing to Facebook Wall

This page was originally written for the 2.x branch of Drupal for Facebook. You're probably using the 3.x branch (or later). The 3.x branch includes a file, modules/fb/contrib/fb_example.module, with code showing the updated API for fb_stream_publish_dialog(). Some of the information that follows is out of date.

Facebook provides a Stream API for publishing content to "streams". These streams include user and page Walls, and also allows you update a user's status. Read Facebook's documentation to get a sense of everything that's possible using these APIs.

Drupal for Facebook includes a module, fb_stream.module, to simplify publishing to Facebook Streams.

fb_stream_publish_dialog()

The fb_stream_publish_dialog() function presents the user with a dialog box. This form allows them to make edits to the content before it is published to their wall, or to skip publishing entirely.

Pages

Subscribe with RSS Subscribe to RSS - Programmers