Is there an easy way to just get the parameter used in the URL in Volt? For example with this URL: ../client/delete/34 I just want to extract 34 - which is the id parameter. (I'm using the standard MVC routes).
Right now I'm using the below work-around with a pass through variable in the controller that works, however I'm left with the feeling that theres also a more simple way to get the parameter directly via Volt.
Been searching for an hour for a different solution but to no afail. Most topics are about getting the parameters via the controller
//controller
public function confirmAction($id)
{
if(!$id) {
$this->flash->error("Client not found");
return $this->dispatcher->forward(["controller" => "client", "action" => "index" ]);
}
$this->view->setVar('id', $id);
}
// view (.volt)
{% extends "layout.volt" %}
{% block title %} Clients {% endblock %}
{% block pagehead %} Client - confirm delete {% endblock %}
{% block flashMessages %} {{ super() }} {% endblock %}
{% block content %}
<div class="box box-success">
<div class="box-header width-border">
<h3 class="box-title">Are you sure you want to delete this client?</h3>
</div>
<div class="box-body">
<div class="row">
<div class="col-xs-12">
<a href="{{ url("client/index/") }}" class="btn btn-default" >Cancel</a>
<a class="btn btn-danger pull-right" href="{{ url("client/delete/" ~ id ) }}" title="delete" ><i class="fa fa-trash"></i> Delete</a>
</div>
</div>
</div>
</div>
{% endblock %}