Is it possible to dynamically change a directory name in <audio src=?
If so, how?
In the example below I would like to change the value of an expression like "$lang_dir" to equal the sub-directory name "english" or "spanish". Thus changing the directory path.
<audio src="http://incentivesonline.com/ivr/$lang_dir/welcome.mp3">
<!-- Play prompt in English or Spanish.
</audio>
We've Moved! Please visit our new and improved forum over at our new portal: https://portal.plumvoice.com/hc/en-us/community/topics
Dynamically change a directory name
-
- Posts: 50
- Joined: Wed Oct 04, 2006 1:34 pm
- Location: SOCAL
- Contact:
You are going to have to use php to build your vxml file. example:
say_something.php
In the above example you will have to make the plum server call the url to that php file. or make one of your goto tags point to this php file.
Hope that helps
Brent
say_something.php
Code: Select all
<?php
print "<?xml version=\"1.0\"?>\n";
print "<vxml version=\"2.0\">\n";
?>
<form id="saysomething">
<audio src="http://incentivesonline.com/ivr/<?php print $lang_dir; ?>/welcome.mp3">
</form>
<?php
// do some other php stuff.. maybe creating other forms or access a db
?>
</vxml>
Hope that helps
Brent
Or you can do a conditional:
- Bil
Code: Select all
<if cond="lang=='en'">
<!-- english -->
<audio src="http://incentivesonline.com/ivr/en/welcome.mp3">
</audio>
<else />
<!-- spanish -->
<audio src="http://incentivesonline.com/ivr/es/welcome.mp3">
</audio>
</if>
- Bil
Dynamically change a directory name
I was able to make it work using the following method which is something like you mentioned in your first reply. I did not include all of the script entries just the ones that were affected. Any comments about this method?
<?php
// this keeps PHP from interpolating <session /> tags in our script
ob_start(); session_start(); ob_end_clean();
echo "<?xml version=\"1.0\"?>\n";
?>
<vxml version="2.0" xmlns="http://www.w3.org/2001/vxml">
<var name="lang_dir" expr="'mp3'"/>
<assign name="lang_dir" expr="'mp3'"/>
or
<assign name="lang_dir" expr="'mp3_s'"/>
<audio expr="'http://incentivesonline.com/ivr/'+lang_dir+'/menu.mp3'">
</audio>
</vxml>
<?php
// this keeps PHP from interpolating <session /> tags in our script
ob_start(); session_start(); ob_end_clean();
echo "<?xml version=\"1.0\"?>\n";
?>
<vxml version="2.0" xmlns="http://www.w3.org/2001/vxml">
<var name="lang_dir" expr="'mp3'"/>
<assign name="lang_dir" expr="'mp3'"/>
or
<assign name="lang_dir" expr="'mp3_s'"/>
<audio expr="'http://incentivesonline.com/ivr/'+lang_dir+'/menu.mp3'">
</audio>
</vxml>
Dynamically change a directory name
Actually I pick up the idea from one of your other forum topics called "inline variables". Thanks again.