L
L
lacrim2015-06-03 03:33:07
Drupal
lacrim, 2015-06-03 03:33:07

How to pass in GET URL with spaces?

An incomprehensible situation arose: there is a site on Drupal, there is a view view, where the link should open a form in colorbox to which get passes the name of the current material.
Code example:

<a class="colorbox-load" href="/form?name=[title]">Отправить</a>

In case [title] (title token) does not contain spaces, everything works with a bang, but if [title] contains, for example, 2 or more words with spaces, etc. problems begin. I’ll say right away - I didn’t have anything to do with get requests before, I understand that I need to somehow screen [title] in my request or convert spaces, for example, to underscores. I will say right away - I googled, I tried to twist it all through urlencode, but apparently my hands were in the wrong place, or my brain was crooked.
I would really appreciate a kick in the right direction!

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Sergey, 2015-06-03
@lacrim

Install this module https://www.drupal.org/project/views_php
First create a php field with something like return urlencode($title);
Then substitute the value of this field instead of [title]

M
Mokhirjon Naimov, 2015-06-03
@zvermafia

Use base64 . Before sending, you encode the data and when you receive it, you decode it.
If I'm not mistaken , base64 was created exactly for this purpose, in order to encode data in a URL .

A
Alexey, 2015-06-04
@AlexFreem

Spaces are successfully replaced by the character combination "%20" which is equivalent to a space.
Further, Drupal can process get-parameters using the drupal_get_query_parameters
function Example:
Processing a request like mysite.com/page?arg=text%20text

$get_params = drupal_get_query_parameters();
echo $get_params['arg'];

Will return "text text" to us.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question