Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Using Variables in Custom Forms Possible?
Hi,
I created a custom form which plays FLV Video. The static version looks like this:
<p>
<div id="player">This text will be replaced</div>
<script type="text/javascript">
var so = new SWFObject('http://10.119.0.15/apache2-default/textpattern/files/player.swf','mpl','320','240','9');
so.addParam('allowscriptaccess','always');
so.addParam('allowfullscreen','true');
so.addParam('flashvars','&file=video.flv&fullscreen=true');
so.write('player');
</script>
</p>
I call this Form like this in my articles:
<txp:output_form form="myvideo" />
But I have a problem at this part of the form:
so.addParam('flashvars','&file=video.flv&fullscreen=true');
I want video.flv be a variable and being parsed in the form. I would like to call it somehow like this – or any other way:
<txp:output_form form="myvideo" video="video1.flv" />
or <txp:output_form form="myvideo" video="video2.flv" />
Is using a form the right solution for my problem?
I tried using existing Plugins like bas_flvplayer but couldn’t get them to work in days! So I try to figure out my own way.
Thanks very much for any suggestions.
Best,
Erik
Offline
Re: Using Variables in Custom Forms Possible?
Hi Erik
Your idea can only be done by a plugin but you can do the same using another view:
create article and put the name of your video in a custom field (call it for ex: video), and create an article form (for ex call it myvideo) with the code:
<p>
<div id="player">This text will be replaced</div>
<script type="text/javascript">
var so = new SWFObject('http://10.119.0.15/apache2-default/textpattern/files/player.swf','mpl','320','240','9');
so.addParam('allowscriptaccess','always');
so.addParam('allowfullscreen','true');
so.addParam('flashvars','&file=<txp:custom_field name="video" />&fullscreen=true');
so.write('player');
</script>
</p>
then you output the result using: <txp:article_custom id=‘article_id” forme =“myvideo” />
and it s done! euh i think
Offline
Re: Using Variables in Custom Forms Possible?
If each article has a different video associated with it, use a custom field (e.g. custom_2) to hold the name of the video you want. Put the video.flv
(or whatever) in that field, then in your form you can do this:
so.addParam('flashvars','&file=<txp:custom_field name="custom_2" />&fullscreen=true');
Of course, you can rename custom_2 to whatever you want via the admin->prefs->advanced tab.
Edit: Dragondz was faster :-)
Last edited by Bloke (2008-07-14 14:58:44)
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
Re: Using Variables in Custom Forms Possible?
Edit: Dragondz was faster :-)
I drink lot of coffee today ;)
Offline
Re: Using Variables in Custom Forms Possible?
Hi,
thanks for your input!
But i suppose only one video per article is possible by the custom field solution?
Best,
Erik
Bloke schrieb:
If each article has a different video associated with it, use a custom field (e.g. custom_2) to hold the name of the video you want. Put the
video.flv
(or whatever) in that field, then in your form you can do this:
so.addParam('flashvars','&file=<txp:custom_field name="custom_2" />&fullscreen=true');
Of course, you can rename custom_2 to whatever you want via the admin->prefs->advanced tab.
Edit: Dragondz was faster :-)
Offline
Re: Using Variables in Custom Forms Possible?
erikscholz wrote:
i suppose only one video per article is possible by the custom field solution?
Yes. But there are a number of ways you could display more than one. sed_pcf allows you to put more than one item in a custom field and iterate over them. So does smd_each. There are probably a few other creative solutions I’ve not thought of using bult-in tags. Perhaps Els or Uli can help you when they read this…?
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
#7 2008-07-14 17:41:02
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Using Variables in Custom Forms Possible?
Bloke wrote:
Perhaps Els or Uli can help you when they read this…?
Why are you doing this to me…? (desperate) ;)
If I understand Erik correctly, he’s using the output_form tags in the article itself and not in the article form because he wants to insert the videos in the article body, something like this maybe?
some text
video
some more text
another video
and text again
If I’m right about this I’m not sure if sed_pcf or smd_each will be of much use here, wouldn’t they only be able to display a number of videos (as defined in the custom field) in a row? (I don’t know the plugins, so apologies if I’m mistaken!)
Erik, is my assumption right? And if so, is there a maximum of videos you need in one article? If you’d only ever need three for instance, you could create three forms like Dragondz said (video1, video2, video3) and use three custom fields.
But I’d still look for a plugin first if I were you, did you try an7_mov?
Offline
Re: Using Variables in Custom Forms Possible?
Hi,
you are absolutely right. I’m back to bas_flvplayer right now. And it won’t work. I continue at this forum entry: http://forum.textpattern.com/viewtopic.php?id=27768
BTW: i tried elkplayer and an7_mov too.
I am i serious trouble folks.
Thanks for any help on the other topic and your already written hints!!
Cheers,
Erik
Els schrieb:
Bloke wrote:
But I’d still look for a plugin first if I were you, did you try an7_mov?
Offline