I have a following Link in zf2
<a href="<?php echo $this->url('application/default',array('controller'=> 'enquiries', 'action'=>'index')) ?>"><?php echo $this->translate('Enquiries') ?></a>
and this router in zf2
'application' => array(
'type' => 'Literal',
'options' => array(
'route' => '/application',
'defaults' => array(
'__NAMESPACE__' => 'Application\Controller',
'controller' => 'Index',
'action' => 'index',
),
),
'may_terminate' => true,
'child_routes' => array(
'default' => array(
'type' => 'Segment',
'options' => array(
'route' => '/[:controller[/:action]]',
'constraints' => array(
'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
),
'defaults' => array(
),
),
),
),
),
which convert above link into
<a href="/application/enquiries/index">Enquiries</a>
which is fine.
I am using angularjs, which uses anchor fragments a lot. How can I add achor "#/active" on above zf2 link url, so target url look something like this.
<a href="/application/bookingenquiries/index#/active">Active Enquiries</a>
do you have a reason why you are not just adding the anchor manually after the url definitionurl(...).'#/active'
?if you have, try this:
UPDATE:
I checked the source for router and uri and url , it seems that url view helper accepts a
'fragment'
key for the third option so try this :Zend/View/Helper/Url
Zend/Mvc/Router/Http/TreeRouteStack
Zend/Uri/Uri
Create following view Helper by extending Url
In Module file add following in factory to add newly created helper
Add anchor in URL as parameter