Experimental project

This is a sandbox project, which contains experimental code for developer use only.

The Static Content module allows to place content as files in the files/ directory – or in additional ones, defined by other modules implementing a hook.

hook_menu() entries will be generated automatically by scanning the contents of the provided directories. On output, the content will be rendered within the theme.

Thus, static content of your site or module can be maintained in the code repository, and created, edited and removed without touching any PHP code.

Usage

As site webmaster

  1. Install and enable the module.
  2. Place content into sites/default/files/static_content/, for instance:
    • sites/default/files/static_content/first/index.html
    • sites/default/files/static_content/first/second/index.html
  3. Clear the menu cache.
  4. In your browser, access first/second and see the content of sites/default/files/static_content/first/index/second.html being rendered within the theme.

As module developer

  1. In your module, implement hook_static_content_dirs(), for instance like:
    
    function YOURMODULENAME_static_content_dirs() {
      $dir = drupal_get_path('module', 'YOURMODULENAME') . '/static_content';
      return array(
        $dir => array()
      );
    }
    
    
  2. Place content in YOURMODULEDIR/static_content, like described above.
  3. Clear the menu cache.
  4. Access like described above.

Advanced

Set a page title in the file

To set a page title for a path, add a HTML comment its HTML file:

<!--
title = This is the title
 -->

The HTML comment should contain settings in .info file format. These settings will be passed to thehook_menu() item array.

Set a page title in the hook

To set a (default) page title for all paths of your module, implement the hook like this:


function YOURMODULENAME_static_content_dirs() {
  $dir = drupal_get_path('module', 'YOURMODULENAME') . '/static_content';
  return array(
    $dir => array('title' => 'Default Page Title')
  );
}

These settings will be passed to the hook_menu() item array when Static Content is registering menu items.

Project Information