Q:

How to dynamically get on url the id on view page in OctoberCMS

i have on controller views page code this button:
<button
<a href="<?= Backend::url('vimagem/pacientes/pacientes/pdf/1') ?>" 
class="btn btn-primary oc-icon-sign-out">export</a>
</button>

how i can get the id of this url ?
<button
<a href="<?= Backend::url('vimagem/pacientes/pacientes/pdf/:id') ?>" 
class="btn btn-primary oc-icon-sign-out">export</a>
</button>

This way is not working... any ideia?

A:

From backend we can get params but we need to use index. just use below code to get id. 

$this->params[0] - will get you first param value.

<a href="<?= Backend::url('vimagem/pacientes/pacientes/pdf/' . $this->params[0]) ?>"

Here index 0 denote that we want to use first param. index count starts after [param]action name and its based on 0-index. so first item has 0 index.

If your back-end controller is using Form-Controller behavior then use this answer both will work.
October CMS | In the controller, create edit button on preview.htm which then links to update.htm with the same ID
if any doubt please comment.

