0

I have a 3 part URL and I am using the url() helper to set the params in my template like this:

<a href="<?php echo $this->escapeHtml($this->url('helpdesk/tickets', array( 'ticketStatus' => 'closed','group' => abcde))); ?>">View closed tickets</a> 

The 'ticketStatus' param is either not being set at all or is being overridden by the default set in the route config (not sure why its not getting set correctly). The 'group' param is getting set correctly though.

Here is the router section of my module.config.php:

'router' => array( 'routes' => array( 'helpdesk' => array( 'type' => 'literal', 'options' => array( 'route' => '/helpdesk', 'defaults' => array( 'controller' => 'Helpdesk\Controller\Helpdesk', 'action' => 'index', ), ), 'may_terminate' => true, 'child_routes' => array( 'tickets' => array( 'type' => 'segment', 'options' => array( 'route' => '/tickets/:ticketStatus/:group', 'defaults' => array( 'action' => 'tickets', 'group' => '', 'ticketStatus' => '', ), 

So when I load the page the url for the anchor is myapp/helpdesk/tickets//abcde.

Whats happening? Why is the url() helper not setting this param?

6
  • double "//" ? How you access group in your controller ? Commented Mar 18, 2014 at 14:12
  • "//" because the default is a blank string '' and url() is not setting it correctly. In the controller I'm doing: $this->params('group'). The group param works fine. Commented Mar 18, 2014 at 14:15
  • so you can add blank status for no status and you can access this data by $this->params()->fromRoute('group', 'ifNoGroupTakeThis'); and $this->params()->fromRoute('ticketStatus', 'ifNoticketStatusTakeThis'); Commented Mar 18, 2014 at 14:18
  • I don't understand, the blank is just a default. I want to be able to set it dynamically with url(). That's not a solution to this issue. I'm misusing url() here or have an incorrect routing configuration- that is the issue I want to understand\resolve. Commented Mar 18, 2014 at 14:24
  • 1
    ok a think there is something wrong in route try change :tickerStatus change to [/:tickerStatus] and /:group to [/:group] and you don't have controller in defaults Commented Mar 18, 2014 at 14:32

1 Answer 1

1

try this : '/tickets[/:ticketStatus][/:group]'

Sign up to request clarification or add additional context in comments.

3 Comments

Did this, removed the default for ticketStatus and it works now, but whyyy? I can live with this, but now I can't make those parameters mandatory. This is so confusing, is there something fundamental I'm missing here? I'm using a standard parent and child route here is this behavior by design?
leave default for ticketStatus (only problem is that dafeult ticketStatus is blank) so if you can make default status like 'default'. i don't know your app but in my opinion ticket should always have status even like 'noStatus' becouse no status is status by definition
I think I might open another thread asking specifically why these params can't be mandatory.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.