Reputation: 3580
In my application, i have:
so basically a one-to-many relationship between the orders table and the orders entries table (should be quite a common structure).
i have a page that display all of a customer's orders (but not the entries). This part is simple, in my OrdersController, i have a viewAllOrdersAction which queries the DB, and send the results to the view for rendering.
Now, the next thing i want to do is, when the user clicks on a specific order, i want to go to a page which shows all the entries for that order.
i suppose i will need to add a viewOrderAction to the OrdersController which again queries the DB and send results to another view.
The question i have is regarding sending the orderId from the viewAllOrders page to the viewOrderAction and retrieving it there.
What is the right way to do this?
Thanks!
Upvotes: 0
Views: 176
Reputation: 60403
Option 2 is the best bet and it would look something like:
<?php echo $this->url(array('order_id' => $this->order->getId()), $viewOrderRouteName); ?>
Now if you didnt have a named route with module, contorller, action speced then you could:
<?php echo $this->url(array(
'order_id' => $this->order->getId()
'module' => 'customer',
'controller' => 'order',
'action' => 'viewOrder'
), 'default' ); ?>
Assuming you have the default route enabled. Note this just ouputs the url not a full a tag
so use in it as the href attrib or use sprintf
to compose the tag... I think there is a generic html tag helper so you could use that as well.
Now if you dont want to expose your order ids in the url you could come up with some sort of other params to select the order itself (although this would require a join query in your view order controller) like customer username && order date or what have you simialr to how you might see a blog permalink as a date && a title "slug".
Upvotes: 1