How to
Information on how to do something... anything.
Comment Module Example
Most of the time, the best way to learn is from looking at core. Randomly clicking around in a Drupal 6 download led us to modules/comment, where we noticed comment-folded.tpl.php. Aha! A template file with that name will probably not be called automatically by Drupal's template systems (as node.tpl.php might). So let's see just how comment.module handles this.
The _theme
hook alerts Drupal to the presence of theming functions and, as in this case, a template:
For a user named agaric:
sudo passwd agaric
From a different server with working id_dsa public key that had been cat'd into authorized_keys:
scp authorized_keys ben@example.org:~
Then back on the server to which we're updating this user, from your own home directory to which you just uploaded the authorized keys file.
sudo mv authorized_keys /home/agaric/.ssh
It worked this time, anyway. Reviewed the diff (for two different revisions? brain/memory not working), and then when it appeared none of the changes conflicted, ran the subversion update.
-bash-3.00$ svn diff sites/default/modules/change_agents/user_profiles/user_profiles.module
Index: sites/default/modules/change_agents/user_profiles/user_profiles.module
$ cvs update -C
[... and a ton more stuff]
cvs update -C will move all the files you have changed to a renamed file and bring down the originals again.
Resolution
<?php
// if the data's not good, send us to the home page
// note: drupal_goto without any arguments sends to / - the front page
// or could use <front> -- url() is called and treats the same
// so this is not necessary:
return drupal_goto(drupal_get_normal_path(variable_get('site_frontpage', 'node')));
// this will do:
return drupal_goto();
?>
Resolution
This is very much a hack, as it puts far too much database loading and PHP logic not even in the theme layer, but worse, embedded in the content itself. A better version might use the theme layer to make the $filename and other such variables available to certain content types with files attached, for instance.
For now... here's the hacky way. But first, some of the research to get us there:
php get first element of array
http://us3.php.net/reset