helo!

i noticed an annoying thing while working on a layout with embeded
flash menu. we use an external xml file to specify menu labels and
links, so when the client want's to change sg, we don't have to bother
with recompiling the swf. the site however is multilingual, so menu
files (which are reside in /webroot/xml/) are named like
menu_en_gb.xml. this way i have to pass the path to the xml file to
the movie.

the problem is with flash's path handling. the movie is loaded fine
everytime (using $html->url('/swf/menu.swf')) but the path to the xml
file needs to be changed according to the url's depth. there's not
much to say about the fla, as the path to the xml is passed as is like
XML.load(path) where path is from swfobject.

so, i don't know exactly why, but i need to modify the xml path to be
passed according to the current url by checking how many slashes it
contains. like when my app url is / the xml path will be ./xml/
menu_en_gb.xml but when the url to a page is like /controller/ the
path have to be changed to ../xml/menu_en_gb.xml or else flash cannot
find the xml, although the swf loads correctly.

this is the code for building the path to xml which is then passed to
the swf:

---
$extrapath = "./";
if (isset($this->params['url']['url']))
{
        $url = $this->params['url']['url'];
        $ct = 0;
        for ($i=0; $i<strlen($url); $i++)
                if ($url[$i] == "/") $ct++;
} else
        $ct = 0;

if ($ct > 0)
        $extrapath = str_repeat('../', $ct);
---

and the chunk in the view:

---
<script type="text/javascript">
        //      <![CDATA[
        var so = new SWFObject("<?php echo $html->url('/swf/menu.swf'); ?>",
"menu", "500", "50", "8", "#7D6F62");
        so.addVariable("live","true");
        so.addVariable("path", "<?php echo $extrapath."xml/menu_$lang.xml"; ?
>");
        so.write("menu");
        //      ]]>
</script>
---

how can i avoid having to bother with this workaround (besides leaving
flash)?


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to