-- is that you john wayne? <[email protected]> wrote
(on Monday, 14 March 2011, 10:05 AM -0700):
> I'm looking to incorporate WURFL within my boostrap.  As such i've been
> following: http://framework.zend.com/manual/en/zend.http.user-agent.html
> 
> I've followed this as accuratly as possible, changing various parts to my
> needs.
> 
> My Application.ini has the following:
> 
> resources.useragent.wurflapi.wurfl_api_version        = "1.1"
> resources.useragent.wurflapi.wurfl_lib_dir            = APPLICATION_PATH
> "/../library/wurfl-php-1.1/"
> resources.useragent.wurflapi.wurfl_config_file        = APPLICATION_PATH
> "/configs/wurfl-config.php"
> 
> My WURFL libs are: library/wurfl-php-1.1/
> My WURFL data files are: data/wurfl/
> My Cache is: tmp/cache/wurfl/
> 
> The error i get is:
> 
> Uncaught exception 'Zend_Http_UserAgent_Features_Exception' with message
> '"wurflapi" configuration is not defined'

Honestly, creating a vanilla application just now with the above
configuration works fine for me.

> My understanding of Zend, which isnt encyclopedic, means that for some
> reason the isnt being called:

No, it goes deeper than that: it would mean that the Wurfl adapter is
not getting the values specified under resources.useragent.wurflapi. The
exception thrown above happens when the adapter can't find wurflapi
configuration, but before it attempts to load the WURFL config file --
i.e., it can't figure out what to load.

> resources.useragent.wurflapi.wurfl_config_file        = APPLICATION_PATH
> "/configs/wurfl-config.php"
> 
> 
> Oh and my wurlf-config.php litterally has:
> 
> echo "Loaded";
> die;
> 
> But this never runs.  
> 
> This only happens when i'm trying to view my application using a smartphone
> useragent ( iphone 3.0 )

That latter makes sense -- it's only when a mobile device is detected
that WURFL will be invoked.

Try the following:

 * Create a new ZF project
 * Enable layouts in that project
 * Add the WURFL library to your project per the manual
 * Add the application.ini settings per the above
 * Create the data/wurfl directory as specified in the manual, and
   populate it.
 * Add the wurfl configuration file as specified in the manual.

I did the above, and then added a plugin (quoted inline in its entierty
below), the configuration to make the plugin load, and some layout view
scripts, and all was well for me.


> Any help or advice would be greatly apprciated.  I did prevously search for
> this problem within the forum, but havent had much joy.  

<?php
class mwop_Plugin_Device extends Zend_Controller_Plugin_Abstract
{
    public function dispatchLoopStartup(Zend_Controller_Request_Abstract 
$request)
    {
        $bootstrap = 
Zend_Controller_Front::getInstance()->getParam('bootstrap');
        $userAgent = $bootstrap->getResource('useragent');

        if ('mobile' != $userAgent->getBrowserType()) {
            return;
        }

        $layout     = $bootstrap->getResource('layout');
        $width = $userAgent->getDevice()->getPhysicalScreenWidth();
        switch (true) {
            case ($width <= 128):
                $layout->setLayout('layout-poor');
                break;
            case ($width <= 176):
                $layout->setLayout('layout-medium');
                break;
            case ($width <= 240):
                $layout->setLayout('layout-high');
                break;
            case ($width <= 320):
                $layout->setLayout('layout-ultra');
                break;
            default:
                // use default
                break;
        }
    }
}

-- 
Matthew Weier O'Phinney
Project Lead            | [email protected]
Zend Framework          | http://framework.zend.com/
PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc

-- 
List: [email protected]
Info: http://framework.zend.com/archives
Unsubscribe: [email protected]


Reply via email to