Ad

How To Dynamically Get On Url The Id On View Page In OctoberCMS

i have on controller views page code this button:

<button
<a target="_blank" rel="nofollow noreferrer" 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 target="_blank" rel="nofollow noreferrer" 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?

Ad

Answer

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 target="_blank" rel="nofollow noreferrer" href="<?= Backend::url('vimagem/pacientes/pacientes/pdf/' . $this->params[0]) ?>"

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

<a target="_blank" rel="nofollow noreferrer" target="_blank" rel="nofollow noreferrer" 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.

Ad
source: stackoverflow.com
Ad