Using flash node with content template
A default installation of flash node is configured to put the flash content at the top of the node, just before the body content. With flash node version six the flash element can be weighted to make it float or sink. If you want to have more fine control then one user found a solution using the Content template module (a.k.a. contemplate).
Contemplate lets you over-ride the teaser and body templates for each content type by writing PHP code.
For example, say you wanted the flash content in teaser view to be displayed at the start of the node, but at 25% of its regular size, while in the full view you are happy with the default flash node presentation.
To do this you would use content template to create a new template for flash node. Using PHP you can manipulate the flash node components of the node object. You then call theme('flashnode', $node->flashnode) to generate the appropriate mark up. So for the example described you might write the following in the teaser template...
<?php
$node->flashnode['height'] = $node->flashnode['height'] * 0.25;
$node->flashnode['width'] = $node->flashnode['width'] * 0.25;
print theme('flashnode', $node->flashnode);
print $teaser;
?>
Now all the teasers will produce the flash elements at one quarter their regular size. Because flash node will also automatically add the flash content to the teaser you would also set the flash node display mode to body only.
Within content template you can access all of the elements of the flash node object and manipulate them before output. You can access the following elements:
- $node->flashnode['_flashnode'] The path to the file that you want to display. Note that as of flash node version 6 this paramter is replaced by $node->flashnode['filepath']
- $node->flashnode['height'] The height, in pixels, for the swf file
- $node->flashnode['width'] The width, in pixels, for the swf file
- $node->flashnode['display'] The display mode, where 0 = teaser and body, 1 = teaser only, 2 = body only
- $node->flashnode['substitution'] The substitution text to use with javascript methods. Or use !default to use the default site setting
- $node->flashnode['flashvars'] A flashvars string to pass to the swf file
- $node->flashnode['base'] The path to use for the base parameter - defaults to the site file directory
[Note 1] This example is written for Drupal 5. A similar technique ought to apply to Drupal 6, although it hasn't been tested at the time of writing!
[Note 2] As contemplate is called after the node is prepared flash node will already have attached the flash mark up to the teaser, the body, or both. Therefore you might need to use a string replacement to strip out the original mark up and then re-attach flash node markup.
Help improve this page
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion