Matt,
I'm doing what I thought was a little project to replace the tags section in the privatemsg module with a Flash object that I can swap in and out to do a practical examination of using psychological tags in communication. The one I've started with is deBono's six hats but the idea is to have other models and just swap the flash object. All sounded very simple on paper.
I kitted myself up pretty well too, I have your module development and JS books and Tidwell's flash in Drupal book. (And I gota say I hope you made some cash out of those books Matt to encourage you to write more, as they are as per the feed back you have got, 'First Class'. Not just the code but damn well written.)
So with a pretty simple project and a 6 week uni deadline and all this kit nothing could go wrong, right. My lecturer loved the idea, got a HD for the design and prototype I'm cooking with gas. Then comes the coding. In one day from a standing start with the help of those resources I'd slapped up the basic module outline.
There were some issues, privatemsg had the tagging removed from the write post section before the release (during the projects timeframe) and the rootcandy theme messed with the privatemsg CSS but undaunted I figure this is nothing I can't work around. Oh look the swftools module is a bit screwy on SWFObject2. No worries I'll use SWFObject1. Bugger that doesn't even show on the install page. jQuery (Lutman) it is then.
Then I post a couple of messages about the place asking for help on this. Replies nil. And I start looking about for some kind of example of this sort of practice. Nothing. This should have been a warning.
Now I've end up with at least 3 ways via JS replacement or form_alter to get [swf file="myflash.swf] to print on a page but none will make it render because the JS code is being filtered no doubt for security. I thought that filtering would only apply to input from the user but clearly I'm wrong.
What I need is something like this...
function privatemsg_form_alter(&$form, $form_state, $form_id) {
if ($form_id == 'privatemsg_new' && user_access('create flashtags')) {
$form['privatemsg']['flashtags'] = array(
'#type' => 'fieldset',
'#access' => user_access('create flashtags'),
'#title' => t('Flash Tags'),
'#collapsible' => FALSE,
'#collapsed' => empty($form['#privatemsg_message']['flashtags']),
'#description' => t('Flashtags are used to add a context to a message and only viewable by the sender.'),
'#prefix' => '<div id="flashtags">',
'#flash' => '[swf file="myflash.swf"]',
'#suffix' => '</div>',
'#weight' => 1,
);
}
}
Really for usability I should do this in HTML and JS something like
$(document).ready(function(){
var flashtag =
$('#flashtags').flash({
src: 'flashtags.swf',
width: 500,
height: 190
});
if (Drupal.jsEnabled) {
try {
$('#flashtags').replaceWith('<p> Flash tag is here ' + flashtag + '</p>');
}catch (error){
alert(error);
}
alert("works");
} else {
alert("broken");
}
});
Where the flash object actually renders and isn't spat out as [swf file="myflash.swf"] or [object Object]. Before I throw any more time at this (like I can damn resist that temptation) do you have some advice for me.
Yani
Comments
Comment #1
gersh commentedWhy do you want Flash in forms? I'm not sure if this even makes sense. Wouldn't it be slow if you are constantly loading flash files?
Comment #2
akayani commentedIt was for an experiment to create a test site for adding intent to the private message module and then scoring that intent. It wasn't just a 'button'. In this case it wouldn't have been an issue with speed. I gave up on the idea as I couldn't find any examples of flash within form code like that.