Reputation: 1068
I want to pass additional params through the URL helper and router - that therefore will not appear in the address bar - but are accessible via the getParam call
My route is below - notice the tagID I want to be passed invisibly though
'router' => array(
'routes' => array(
'tag' => array(
'route' => '/tag/:tag',
'defaults' => array(
'module' => 'default',
'controller' => 'tags',
'action' => 'profile',
'tag' => '',
'tagID' => ''
)
)
)
The URL helper specifies the TagID
url(array('tag' => $tag, 'tagID' => $v->id), 'tag', true) ?>
Basically is this possible to then get the address bar to show
localhost.com/tag/php
but the controller to have access to the tag and tagID params?
Cheers
Ian
Upvotes: 0
Views: 1453
Reputation: 659
This isn't possible as far as I know. There's nowhere to hide any variables because you're dealing with a standard GET request. This is really about the http protocol, not Zend.
There are two ways of moving data/state between urls: GET (i.e. Encoded into the actual URL and POST.
As a POST request isn't appropriate here you're unfortunately stuck with visible URL parameters, or reconstructing the tagID from the tag name on the receiving page.
Upvotes: 1
Reputation: 2911
In your action use:
$tagId = $this->_getParam('tagId', 'yourDefaultValue');
Upvotes: 0
Reputation: 30002
If you add a route for each tag, you can assign defaults for them and you won't need to explicitly define them in the url.
Like this (foreach tag):
'route' => '/tag/php',
'defaults' => array(
'module' => 'default',
'controller' => 'tags',
'action' => 'profile',
'tag' => 'php',
'tagID' => 'phpID'
)
Upvotes: 1