RDF Mapping API

The RDF Mapping API allows you to expose your site's data for easy re-use by mapping bundles to RDF types and fields to RDF predicates. This abstract mapping can then be used to publish the content contained in these bundles, enabling you to serialize the RDF into a number of different formats, such as RDFa, RDF/XML, or populate a SPARQL endpoint.

For an introduction to RDF, some use cases, and an overview of its use in Drupal, see the documentation in the Site Building section.

ARCHIVE: Views Index (A-Z Grouping)

There have been many support requests and forum topics about creating an index page with views although there seems to be little information on how to achieve it.
It is relatively simple when you know how, and using grid formatting and grouping we'll build an index page that will look sort of like this:

A
Node Title | Node Title | Node Title

B
Node Title | Node Title | Node Title
...

The view export below will display all nodes in the above fashion. Once you have imported this view create a new php file in your current theme folder:
views-view-field--index--title.tpl.php (don't forget to clear cache)

<?php
print strtoupper($output[0]);
?>


$view = new view;
$view->name = 'index';
$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' => '',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'help' => '',
'trim' => 0,

Module Architecture

Presets

OpenLayers presets contain

  • Map Settings
    • Height, width
    • Centerpoint
    • OpenLayers source file, theme location, ProxyHost
  • Enabled Behaviors
  • Enabled Layers
  • Enabled Styles

OpenLayers Map Views

OpenLayers map views use the Views module merely as a way to put a map on a page. They do not, like other views, query data by themselves. To add Drupal nodes or data to a OpenLayers map view, enable openlayers_views and create a OpenLayers Map Data view, and add it as a layer.

OpenLayers Map Views pull from OpenLayers Presets

Layer Types

Layer types are plugins. A base set of layer types is provided within the OpenLayers module, and other contrib modules like MapBox can provide even more. Layer Types generate Layers and provide their functionality

Layers

Layers are exportables which contain per-layer configuration.

Styles

Styles are exportables which contain OpenLayers Styles. They are attached to layers by the configuration in Presets.

Plain-English Explanation

Styles are exportables, as simple as that, they don't have any functionality and have a very simple interface.

Bluga WebThumbs

The Bluga WebThumbs module provides a very complete implementation of the Bluga WebThumb API. It does not, however, provide much else. The most useful (and intended) use of this module is either to be used by other modules wishing to build on it or provide a way for a Drupal site with a custom theme to display a thumbnail based on the content of a node. This can be used with a custom PHP filter if you prefer as well.

Configuration

  • Here you will need to enter your API key. The link to sign up for an account is on that page.
  • You will also select a directory under which to store your thumbnails. The configuration screen will warn you if the directory needs to be created or made accessible for writing.

    Creating a Thubmnail

    The basic syntax is:

    <?php
    print bluga_webthumb('http://drupal.org');
    ?>
  • API: Styles

    OpenLayers styles definitions are a light wrapper around the functionality provided by styles in the OpenLayers javascript library. A simple style definition (one of the defaults included by the module) is

    <?php
    /**
     * Implements hook_openlayers_styles().
     */
    function modulename_openlayers_styles() {
     
    $styles = array();
     
    $style = new stdClass();
     
    $style->api_version = 1;
     
    $style->name = 'default';
     
    $style->title = t('Default style');
     
    $style->description = t('Basic default style.');
     
    $style->data = array(
       
    'pointRadius' => 5,
       
    'fillColor' => '#FFCC66',
       
    'strokeColor' => '#FF9933',
       
    'strokeWidth' => 4,
       
    'fillOpacity' => 0.5
     
    );
     
    $styles[$style->name] = $style;
      return
    $styles;
    }
    ?>

    The contents of $style->data are passed directly to the OpenLayers javascript, and therefore have documentation on OpenLayers.org.

    Coded Styles

    To provide custom styles in a module or feature, implement hook_openlayers_styles(), and return an array of styles, keyed by style name (like seen above).

    Also, in order to tell CTools about your new hook, you will have to implement the following hook, like so:

    <?php
    /**

    HOW TO: Remove inactive fields

    While working on the migration of CCK fields from D5 to D6, you may find that once you have finished upgrading the modules and data to the new version, there are still a few fields that were part of an old version that does not exist in your new D6 installation, and you may now need to remove these fields. Please, read related discussion in the CCK issue queue: #258458: Can't delete inactive fields through the API.

    If you need to remove a field instance from the system, you should use content_field_instance_delete(). However, this function can only be used to process active fields (more about this later). Here's an example:

    <?php
     
    // Load the file that implements CRUD (Create, Read, Update and Delete) methods in CCK.
     
    module_load_include('inc', 'content', 'includes/content.crud');

     
    // Delete a field instance.
     
    content_field_instance_delete($field_name, $type_name);
    ?>

    Here's an example to delete all the fields implemented by a particular module:

    <?php
      module_load_include
    ('inc', 'content', 'includes/content.crud');
     
    content_module_delete($module);
    ?>

    The above example is equivalent to do the following:

    <?php
     
    // This deletes all fields implemented by $module from the content tables.
     
    content_notify('uninstall', $module);
    ?>

    Note that the above example is used in the implementation of hook_uninstall() of all modules that implement CCK fields.

    Pages

    Subscribe with RSS Subscribe to RSS - Programmers