Created a New Zend Controller but can't access when Specified in Layout? -


i created new controller with:

zf create controller email 

but resulting files weren't put in application/modules, put in application/...

anyway moved controller , view files correct directory

then used:

<a href="<?php echo $this->url(array(), 'email');?>">email</a> 

after refresh page gives internal error 500

don't know what's cutting -> it's zend version: 1.12.1

$this->url() view helper works matching parameters given , route name, create uri.

in order code work, have to:

1 - in router file, specify route, example:

    $router->addroute(         'email',          new zend_controller_router_route_regex('([\w\d\.\_]+)@([\w\d\.]+)([\s]*)',             array(                 'module' => 'default',                 'controller' => 'index',                 'action' => 'index'             ),             array(                 1 => 'username',                 2 => 'host'             ),             '%s@%s'         )     ); 

the first param addroute name of route , that's use second parameter $this->url(). second parameter router adapter. there many different adapters (check manual), 1 regex adapter.

first param - regex string checking uri. want modify more e-mail wise regex, should enough.

the second param defaults.

the third - variables. each group in regex should specify name, group before @ become 1 => 'username' , after - 2 => 'host'.

and fourth param - important - reversed route. 1 1 zend uses glue pieces. create changing each group "symbol", whole thing becomes "%s@%s" - you'll have read articles on how create - go %d digits only, %w letters , %s mixed, didn't ever need more.

2 - after setup router, go view file , modify function looks this:

    $this->url(array('username' => 'test', 'host' => 'test.com'), 'email'); 

your resulting html should this:

<a href="test@test.com">email</a> 

3 - turn on error_reporting, either in server configuration or zend application ini file. you'll have greater insight what's malfunctioning.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

mysql - Pass value between different pages (form) with PHP -