Search code examples
twigopencart-3

How to get user_token value from the URL


In an OpenCart framework version, 3.0.2.x, for the

URL = http://localhost/moreshop/admin/index.php?route=account/apisync&user_token=FARboCmeZHqQl8bITE3SRTenJscadbYc

I need to get the URL value from the parameter user_token that is written in the .twig format

Previously with OpenCart version 2.3.x.x, this was written in the .tpl file as

<input type="hidden" name="token" id="token" value="<?php echo $_GET['token']; ?>"/>


I had tried to assign the value =

{{ app.request.query.all }}
{{ app.request.query.get('user_token') }}
{{ app.request.get('user_token') }}
{{ _GET.user_token }}

But all the above value assigned with null. So how do I get the value of the user_token and assign into value=?


Solution

  • You should define it in your controller file:

    $data['user_token'] = $this->session->data['user_token'];

    Than you can call it in twig file:

    <input type="hidden" name="User_token" id="user_token" value="{{ user_token }}"/>
    

    you also can try call it {{ _GET.token }}