koushik
koushik

Reputation: 1

How to define href of an anchor tag in html for zend framework 2?

in the module\Application\config\module.config.php // the routes are looks like this.

'application' => array(

            'type' => 'Literal',
            'options' => array(
                'route' => '/',
                'defaults' => array(
                    '__NAMESPACE__' => 'Application\Controller',
                    'controller' => 'Index',
                    'action' => 'index',
                ),
            ),
            'may_terminate' => true,
            'child_routes' => array(
                'default' => array(
                    'type' => 'Segment',
                    'options' => array(
                        'route' => '[:controller[/:action]][/:id]',
                        'constraints' => array(
                            'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
                            'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
                        ),
                        'defaults' => array(
                        ),
                    ),
                ),
            ),
        ),

i have two action namely index and store. i have one controller namely IndexController

now in my view there are layout namely layout.phtml in that file i have an anchor tag.

<a href="?">store</a>

now what will be the answer of the question mark in the just above line?

Upvotes: 0

Views: 1614

Answers (1)

Tim Fountain
Tim Fountain

Reputation: 33148

Are you asking how to output a link to one of your routes? If so, you use the URL helper:

<a href="<?=$this->url('application/default', array('controller' => 'index', 'action' => 'store')?>">store</a>

Upvotes: 2

Related Questions