简体   繁体   中英

Zend Framework, FusionCharts, PHP, Javascript

Kind of a weird one here: I have a Zend Framework setup in 1.12. My models are working fine and all of my includes are set...but in the view Zend can't seem to find a FusionCharts.js file that is there. I have it appended in the action as follows and when I check the path on Firebug it is absolutely correct- but still returns an error and claims that it can't find the .js file. Anyways- here's the code:

public function indexAction()
    {
        try{
            $model = new Application_Model_DbTable_Daily;
            $dau = $model->getStats();
            $this->view->dau = $dau;
        }
        catch(Exception $e) {
            $this->view->dau = $e;
        }
        $this->view->headScript()->appendFile('/dashboard/public/fusioncharts/Charts/FusionCharts.js');
    }

So- in my view I get:

<?php
echo $this->headScript();

echo "<pre>";
     $FC = new FusionCharts("Line", "500", "300");
     $FC->setSwfPath("/public/fusioncharts/Charts/");
     $strParamDAU = "caption=Daily Active Users;streamlinedData=0;decimals=0;decimalPrecision=0;formatNumberScale=0;slantLabels=1;labelDisplay=ROTATE";
     $FC->setChartParams($strParamDAU);
     foreach($this->dau as $k=>$v) {
         $FC->addChartData($v['session_date'], "label=" . $v['DAU']);
     }
    $FC->renderChart();

echo "";

But when I look at the view in firebug I get an error saying that it can't find FusionCharts.js in the public directory (the path is definitely right!). Any ideas why this would be happening? It's there. The Firebug reads the right directory (GET localhost/dashboard/public/fusioncharts/Charts/FusionCharts.js) but the firebug error is saying that it can't see the file. Thanks for the help!!

If the file is realy there, and the Name is FusionCharts.js:

Try to add the BaseUrl (just to be on the safe side):

$this->view
     ->headScript()
     ->appendFile($this->view->baseUrl() . '/dashboard/public/fusioncharts/Charts/FusionCharts.js');

Next check your .htaccess, maybe you arent forwarding JS Files? Correct .htaccess:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM