0
votes

I have reached a point where my ambition has exceeded my ability implementing Dojo in a Zend Framework project using an XAMPP distribution for PHP & Mysql as my dev/test environment on a Windows 7 machine. I honestly don't know if this is an ID10T issue (me) or a system failure. Should this be a failing on my part I apologise in advance.

I'm trying to implement using the V1.7 version of Dojo while remaining on a production ready environment (hence avoiding the jump to ZF 2, etc). I'm aware from documentation that in Dojo V1.7 dojo.xd.js has been superceded by dojo.js. My problem lies in trying to use a CDN source for Dojo.

The dojo content of my page renders fine, but Firebug is showing an error "NetworkError: 404 Not Found - http://ajax.googleapis.com/ajax/libs/dojo/1.7/dojo/dojo.xd.js" & the page has the following embedded in the page head:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/dojo/1.7/dojo/dojo.xd.js"></script>

Tracing the source of the problem on my page indicates it is the 'echo $this->dojo;' statement that introduces the problem. Changing the 'setCdnVersion(1.7)' to 'setCdnVersion(1.6)' in the bootstrap file resolves the problem, but I'd really like be using V1.7+.

Pasting the embedded URI into the address bar, indeed, returns a 404 page not found. Dogpile has no references to this specific error, that I can see. I can't find any bug reports that appear - to my limited knowledge - relevant on dojotoolkit.org

It looks like the Dojo config I have is not recognising the need to use the dojo.js for V1.7 (although I'm not sure where the problem actually lies). So, I must confess I'm at a loss how to resolve this problem other than casting myself upon the mercy of the collective SO expertise.

bootstrap.php:

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
...
protected function _initView ()
{
    // Initialize view
    $view = new Zend_View();
    $view->setEncoding('UTF-8');
    $view->headMeta()->appendName('Content-Type', 'text/html; charset=UTF-8');

    // add dojo helper path to view
    $view->addHelperPath('Zend/Dojo/View/Helper','Zend_Dojo_View_Helper');

    // configure Dojo view helper, disabled...
    $view->dojo()
                 ->disable()
                 ->setCdnVersion(1.7)
                 ->setCdnBase(Zend_Dojo::CDN_BASE_GOOGLE)
                 ->addStyleSheetModule('dijit.themes.tundra')
                 ->setDjConfigOption('parseOnLoad', TRUE)
                 ->setCdnDojoPath(Zend_Dojo::CDN_DOJO_PATH_GOOGLE)  
                 ->useCdn();

    // Add it to the ViewRenderer
    $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer');
    $viewRenderer->setView($view);

    // Return it, so that it can be stored by the bootstrap
    return $view;
}

}

In index.phtml:

<head>
<?php echo $this->headLink()->prependStylesheet($this->baseUrl() . '/assets/css/site.css'); ?>

<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/dojo/1.7/dijit/themes/tundra/tundra.css">
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/dojo/1.7/dojox/grid/resources/Grid.css">
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/dojo/1.7/dojox/grid/resources/tundraGrid.css">
<?php 
    // Dojo plug-in enablers ...
    echo $this->dojo(); 
    $this->dojo()->enable();
?>

Version information: Xampp dist - V1.7.7 (Apache/2.2.21, PHP/5.3.8) Zend Framework dist - V1.11.11

1

1 Answers

1
votes

From the 1.7 release notes:

Please note that if you are upgrading from 1.6 or earlier, we no longer make a distinction between dojo.js and dojo.xd.js (all versions work cross-domain with the new loader), so update your URLs to refer to dojo.js.

so the Dojo helper is using the filename dojo.xd.js (the cross domain version), but in 1.7 it should be just dojo.js. Dojo 1.7 was released after the Dojo integration into ZF, so it's possible this is a bug in ZF itself.