Kolego, nie wiem, czy aby na pewno rozumiem o co Ci chodzi z tym routingiem, ale jeśli chcesz, aby adres:
www.mojastrona.pl/?_escaped_fragment_=gallery-1-13
był rozpoznawany jako wywołanie takie, jak przy standardowym routingu: /gallery/foto/param1/1/param2/13,
to można to zrobić w taki sposób:
w folderze library/App/Controller/Router/Route utwórz plik Googlebot.php i umieść w nim kod:
/**
* Rozpoznaje urle googlebota do indeksowania stron ajaxowych.
*/
class App_Controller_Router_Route_Googlebot extends Zend_Controller_Router_Route_Regex
{
/**
* @param Zend_Config $config
* @return App_Controller_Router_Route_Googlebot
*/
public static function getInstance
(Zend_Config
$config) {
$defs = ($config->defaults instanceof Zend_Config
) ?
$config->defaults->toArray() : array(); $map = ($config->map instanceof Zend_Config
) ?
$config->map->toArray() : array(); $reverse = (isset($config->reverse)) ?
$config->reverse : null; return new self($config->route, $defs, $map, $reverse);
}
/**
* @see Zend_Controller_Router_Route_Regex::match()
* @param Zend_Controller_Request_Abstract $request
* @return array|false
*/
public function match($request)
{
if (!$request instanceof Zend_Controller_Request_Abstract) {
return false;
}
$path = $request->getParam('_escaped_fragment_');
return false;
}
return parent::match($path);
}
/**
* @see Zend_Controller_Router_Route_Regex::getVersion()
* @return integer
*/
public function getVersion()
{
//musi być zwracane 2 aby do metody match() jako parametr przekazywało obiekt request
return 2;
}
}
następnie do pliku konfiguracyjnego (standardowo application/configs/application.ini) dodaj:
Kod
resources.router.routes.foto.type = "App_Controller_Router_Route_Googlebot"
resources.router.routes.foto.route = "gallery-(\d+)-(\d+)"
resources.router.routes.foto.defaults.controller = "gallery"
resources.router.routes.foto.defaults.action = "foto"
resources.router.routes.foto.map.1 = "param1"
resources.router.routes.foto.map.2 = "param2"
Żeby ładowało automatycznie klasę App_Controller_Router_Route_Googlebot, dodaj też:
Kod
autoloadernamespaces[] = "App"
W każdym razie u mnie działa (sprawdziłem na szybko na projekcie, który mam na warsztacie), więc u Ciebie też powinno