Site users

OpenLayers Layer Type API

Last modified: November 11, 2009 - 17:20

The OpenLayers module supports layer types, which are ctools plugins. Layer types are related to layers: layers are exportables which contain per-layer configuration, like map server URLs and parameters. Layer types are plugins which provide the forms necessary to create new layers and the functionality of those layers on a map. For instance, the openlayers_views layer type contains the method required to pull data from views and insert it into its own features array.

For instance, the code of the MapBox layer type is

<?php
class openlayers_layer_type_mapbox extends openlayers_layer_type {
/**
* Provide initial values for options.
*/
function options_init() {
return array(
'maxExtent' => array(-20037508.34,-20037508.34,20037508.34,20037508.34),
'baselayer' => TRUE,
'serverResolutions' => openlayers_get_resolutions('900913'),
'resolutions' => openlayers_get_resolutions('900913'),
'maxExtent' => openlayers_get_extent('900913'),
'projection' => array('900913'),
'baselayer' => TRUE,
'layer_handler' => 'MapBox',
);
}

/**
* Options form which generates layers
*/
function options_form() {
return array(
'layername' => array(
'#type' => 'textfield',
'#title' => t('Layer Name'),

Installation

Last modified: December 1, 2009 - 10:07
  1. Download the module from Drupal.org and save it to your modules folder (sites/all/modules)
  2. Copy chatroomread.php from the chatroom module folder to the webroot of your site. chatroomread.php should sit next to your index.php file
  3. Enable the module at admin/build/modules
  4. Enable access to chatrooms and chat for some roles on your site

OpenLayers Tutorial

Setting up a Map

  1. Download and enable the OpenLayers module and the ctools module
  2. You'll also want to download the Views module if you want to display any Drupal data on a map.
  3. Enable OpenLayers, OpenLayers UI, and OpenLayers Views (in addition to Views and the other required modules).
  4. Create a view (e.g. page) and set "OpenLayers" as the Style setting (if you just want to see something skip to step 8).
  5. Go to the OpenLayers administration page (admin/settings/openlayers) and the layers tab. Add a new layer if desired.
  6. Go to the OpenLayers administration page (admin/settings/openlayers) and the presets tab. Create a new preset with a map layer and the view you created before will be an option as an overlay layer.
  7. Save your new map preset and go back to the views interface.
  8. Using the gear/settings option under Style: 'OpenLayers' and edit the options to your liking.
  9. Save your view.
  10. View the view and its generated map.

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

Texy! filter

Last modified: November 7, 2009 - 14:35

The module filters an easy to read Texy syntax into XHTML.

Texy! allows you to enter content using an **easy to read** Texy syntax which is filtered into *structurally and typographically valid* XHTML. No knowledge of HTML is required. Texy! is one of the most extensive formatting tools. It allows adding of images, links, nested lists, tables and has a full support for CSS.

This page needs update.

Hierarchical Select Node Reference

Last modified: November 7, 2009 - 10:29

Overview

This module allows the use of Hierarchical Select form element as a widget for CCK node reference field, both in node add/edit form and in views filter.

Installation

See README.txt for detailed installation instructions

Syndicate content
 
 

Drupal is a registered trademark of Dries Buytaert.