I am trying to create a dynamic reusable menu for use on my application. I have a very basic route that has :id in it which represents the record id. In the submenu I want this :id to be replace dynamically with the record that the user is currently interacting with. Please see below for complete details.
Here is my Route
'item' => array(
'type' => 'Literal',
'options' => array(
'route' => '/Item/',
'defaults' => array(
'__NAMESPACE__' => 'ReserveAnything\Item\Controller',
'controller' => 'Index',
'action' => 'index',
),
),
'may_terminate' => true,
'child_routes' => array(
'default' => array(
'type' => 'Segment',
'options' => array(
'route' => '[:action][/][:id]',
'constraints' => array(
'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id' => '[0-9]+',
),
'defaults' => array(
),
),
),
Here is my navigation file
return array(
'navigation' => array(
'default' => array(
'overview' => array(
'label' => 'Edit Item',
'route' => 'item/default',
'action' => 'Edit',
'params' => array(
'id' => 0,
)
),
'extras' => array(
'label' => 'Manage Extras',
'route' => 'item/default',
'action' => 'Extras',
'params' => array(
'id' => 0,
),
),
),
);
And finally here is my view
echo $this->navigation('navigation')->menu();
Now the output of this is
<ul class="navigation">
<li>
<a href="/Item/Edit/0">Edit Item</a>
</li>
<li>
<a href="/Item/Extras/0">Manage Extras</a>
</li>
Now this would be prefect if I was on Id 0 however if I am on Id 1 (/Item/Edit/1) it would obviously still appears in the above example. How can I get the menu to update the Id inside the config. I imagine this can be done. My Ideal output for when I was editing record Id 1 would be
<ul class="navigation">
<li>
<a href="/Item/Edit/1">Edit Item</a>
</li>
<li>
<a href="/Item/Extras/1">Manage Extras</a>
</li>