It's a easy way to encode url in drupal 8 twig template. We just have to follow the simple steps:
Step 1. First create a variable like given example.
Example:
{% set return_url = render_var(url('<front>')) ~ 'contact?msg=success®ion=americas' %}
Description: here
return_url is the variable name and
url('<front>') is the front page url and
contact?msg=success®ion=americas this section we are concating with " ~ " Tilde sign and
render_var is the render that full url.
Step 2. Now we have to pass the url in src like given example.
Example: https://www.google.com?Return_URL={{ return_url|url_encode}}
Description: So just call the "return_url" with "url_encode" function in url query string. That will return the encoded url.
Note: If have any suggestions or issue regarding 'How to encode url in drupal 8?' then you can ask by comments.
Step 1. First create a variable like given example.
Example:
{% set return_url = render_var(url('<front>')) ~ 'contact?msg=success®ion=americas' %}
Description: here
return_url is the variable name and
url('<front>') is the front page url and
contact?msg=success®ion=americas this section we are concating with " ~ " Tilde sign and
render_var is the render that full url.
Step 2. Now we have to pass the url in src like given example.
Example: https://www.google.com?Return_URL={{ return_url|url_encode}}
Description: So just call the "return_url" with "url_encode" function in url query string. That will return the encoded url.
Note: If have any suggestions or issue regarding 'How to encode url in drupal 8?' then you can ask by comments.
No comments:
Post a Comment