Node copyright info using TOKEN, CCK and VOODOO ;)
I have recently tried out the CC-lite module on a test server and found I liked it a lot. Unfortunately it doesn't fit the bill for a site I might make for a journalists league.
So I started to think about creating a Copyright node-type to encapsulate any/all copyrights needed.
Then I played with the http://creativecommons.org/license/ page and created the following for embedding into a text field in the Copyright node:
[title] by [author-name-raw] is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Norway License.
Permissions beyond the scope of this license may be available at http://[site-url]/copyright.
Note how I have used tokens inside the HTML.
Problem 1
Then I realized that the tokens will be replaced with the info pertaining to the Copyright node I made, and of course not the node which references it.
How would I work around that problem? I would probably have to create a computed field, which goes into the Copyright template, gets the original text, and do token replacement using the current nodes info? Then the user can just get a drop down of all allowed copyrights.
Or is there any non programmatic way of doing this without setting up too much work for the user? Perhaps I could use a computed field, and let the Copyright node reference field just give the names of the copyrights and then try to construct the above link in a switch statement?
Problem 2
How do I let a computed field push info into the html head in order to create html relative links for the copyright info? I think I'll try out http://api.drupal.org/api/function/drupal_set_html_head/6 it seems to fit the bill.

Problem 2 solved
I did the following using CCK and Computed Field:
$content[type] = array (
'name' => 'test',
'type' => 'test',
'description' => '',
'title_label' => 'Tittel',
'body_label' => 'Body',
'min_word_count' => '0',
'help' => '',
'submitagain' => 0,
'node_options' =>
array (
'status' => true,
'promote' => true,
'sticky' => false,
'revision' => false,
'revision_moderation' => false,
),
'autosave' => 0,
'language_content_type' => '0',
'upload' => '1',
'show_preview_changes' => 1,
'creativecommons_lite' => 0,
'pingback' => '0',
'scheduler' => 0,
'scheduler_touch' => 0,
'i18n_node' => '1',
'prepopulate_allowed' => 1,
'i18nsync_nodeapi' =>
array (
'author' => false,
'status' => false,
'promote' => false,
'moderate' => false,
'sticky' => false,
'revision' => false,
'parent' => false,
'taxonomy' => false,
'comment' => false,
'files' => false,
'field_copyright' => false,
'field_copy' => false,
),
'old_type' => 'test',
'orig_type' => '',
'module' => 'node',
'custom' => '1',
'modified' => '1',
'locked' => '0',
'comment' => '2',
'comment_default_mode' => '4',
'comment_default_order' => '1',
'comment_default_per_page' => '50',
'comment_controls' => '3',
'comment_anonymous' => '0',
'comment_subject_field' => '1',
'comment_preview' => '1',
'comment_form_location' => '0',
'composite_enabled' => 0,
'composite_referenceable_types' =>
array (
'edition' => false,
'forum' => false,
'ifimage' => false,
'media' => false,
'page' => false,
'source' => false,
'story' => false,
'test' => false,
),
'composite_advanced_view' => '--',
'composite_advanced_view_args' => '',
'print_display' => 1,
'print_display_comment' => 0,
'print_mail_display' => 1,
'print_mail_display_comment' => 0,
'print_pdf_display' => 1,
'print_pdf_display_comment' => 0,
'taxonomy_multi' => 0,
'unique_field_scope' => 'type',
'unique_field_comp' => 'each',
'unique_field_fields' =>
array (
'title' => false,
'field_copyright' => false,
'field_copy' => false,
),
'xmlsitemap_node_type_priority' => '0.5',
'xmlsitemap_old_priority' => '0.5',
'ant' => '0',
'ant_pattern' => '',
'ant_php' => 0,
);
$content[fields] = array (
0 =>
array (
'label' => 'copyright',
'field_name' => 'field_copy',
'type' => 'computed',
'widget_type' => 'computed',
'change' => 'Change basic information',
'weight' => '31',
'description' => '',
'default_value' =>
array (
),
'default_value_php' => '',
'tokenize' => '',
'group' => false,
'required' => 1,
'multiple' => '0',
'code' => '$copyright = \'<LINK REL=Copyright HREF="/copyright.html" TITLE="Copyright Notice">\';
$node_field[0][\'value\'] = $copyright;
drupal_set_html_head($copyright);',
'display' => 1,
'display_format' => '$display = $node_field_item[\'value\'];
drupal_set_html_head($display);',
'store' => 1,
'data_type' => 'varchar',
'data_length' => '255',
'data_default' => '',
'data_not_NULL' => 0,
'data_sortable' => 0,
'op' => 'Save field settings',
'module' => 'computed_field',
'widget_module' => 'computed_field',
'columns' =>
array (
'value' =>
array (
'type' => 'varchar',
'length' => '255',
'not NULL' => 0,
'sortable' => 0,
),
),
'default_value_widget' => NULL,
'display_settings' =>
array (
'label' =>
array (
'format' => 'above',
'exclude' => 0,
),
'teaser' =>
array (
'format' => 'default',
'exclude' => 0,
),
'full' =>
array (
'format' => 'default',
'exclude' => 0,
),
4 =>
array (
'format' => 'default',
'exclude' => 0,
),
2 =>
array (
'format' => 'default',
'exclude' => 0,
),
3 =>
array (
'format' => 'default',
'exclude' => 0,
),
'token' =>
array (
'format' => 'default',
'exclude' => 0,
),
),
),
);
$content[extra] = array (
'title' => '-5',
'body_field' => '0',
'menu' => '-2',
'attachments' => '30',
);
and the link shows in the site navigation bar of Opera. Now it just needs to be fine tuned. I can also see how to use this trick for a lot of other cool stuff.
Off to the laboratory again.
In http://drupal.org/node/356711 I show how to enhance the computed field to make a pretty good Dublin Core and HTML head link functionality.
Paul K Egell-Johnsen
Problem 1 Mostly Solved
I created a computed field for Dublin Core and Head link tags and a computed field and a copyright node type in Creative Commons and Copyright.
Some stuff todo, but at its most basic it gives me full control of what I need to do.
Paul K Egell-Johnsen