Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

variable url embeds


Not that good at php myself ( understatement)

I would like to insert a variable inside a html page
for example, I would code something like this into the page manually for every page in the html
//
<script>
var playlist= 'playlist: "urltorssfeed.xml"';
</script>

//
Then in the block of my pages, rendered from php and phtml blocks I would have a default JW Player embed setup completely and just want to pass the variable URL into the output, making the playlist variable part of the output embed,

Anyone know how to do this?
Cheers

7 Community Answers

Todd

JW Player Support Agent  
0 rated :

You could use PHP to pass a value in the URL and then insert it into your HTML code:

http://www.test.com/video.php?id=urltorssfeed

and then your PHP code would need something like this:

<?php

$thisUrl = $_GET[‘id’].“.xml”;

print "
<script src=your_jwplayer.js></script>
<div id=myVideo></div>
<script> jwplayer('myVideo').setup({ playlist: $thisUrl }); </script> “;

?>

mark

User  
0 rated :

Hi Todd. Thanks.
I get the bottom php bit but not what I am doing in the top bit
Is this wrapped in a script?

mark

User  
0 rated :

sorry, I get it, you want the URL of the page to be that,,, unfortunately no I cant do that. All I can do is make a variable in the html part of the page

Todd

JW Player Support Agent  
0 rated :

so then define the variable directly in the code:

$thisUrl = “urltorssfeed.xml”;

mark

User  
0 rated :

like this? Not work :(

<script>
$thisUrl = "urltorssfeed.xml";
</script>

Todd

JW Player Support Agent  
0 rated :

Sorry for not being more clear:

<?php

$thisUrl = “urltorssfeed.xml”;

print "
<script src=your_jwplayer.js></script>
<div id=myVideo></div>
<script> jwplayer('myVideo').setup({ playlist: $thisUrl }); </script> “;

?>

I do not know of a way to send variables from a Javascript <script> tag to PHP since PHP usually want to process everything before sending out the HTML code. You could potentially use PHP to make an AJAX request as the page loads to get the desired value, but that would be a topic for a different forum, not ours. If you could explain your use case a little more, perhaps I could come up with a better code example for you. What problem are you trying to solve?

mark

User  
0 rated :

thanks for the suggestions but I couldn't get it to work, I think because the php is loaded before any variables I set... over my head

This question has received the maximum number of answers.