Static content
Categories
Component ID
Component name
Component type
Maintenance status
Development status
Component security advisory coverage
Component created
Component changed
Component body
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
- Install and enable the module.
- Place content into
sites/default/files/static_content/, for instance:sites/default/files/static_content/first/index.htmlsites/default/files/static_content/first/second/index.html
- Clear the menu cache.
- In your browser, access
first/secondand see the content ofsites/default/files/static_content/first/index/second.htmlbeing rendered within the theme.
As module developer
- 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() ); } - Place content in
YOURMODULEDIR/static_content, like described above. - Clear the menu cache.
- 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.
