Page 1 of 1

Dynamically change a directory name

Posted: Wed Apr 25, 2007 8:10 pm
by vmagic
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>

Posted: Thu Apr 26, 2007 1:50 pm
by brent.russell
You are going to have to use php to build your vxml file. example:

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>
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

Posted: Thu Apr 26, 2007 4:04 pm
by bilcorry
Or you can do a conditional:

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

Posted: Thu Apr 26, 2007 4:27 pm
by vmagic
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>

Dynamically change a directory name

Posted: Thu Apr 26, 2007 4:36 pm
by vmagic
Actually I pick up the idea from one of your other forum topics called "inline variables". Thanks again.