1

Whenever I try to pass a variable through url with the l() function like:

l(t($row['salon_name']),'admin/content/edit-salons-products-services?sid='.$row[salon_id] );

? is replaced by "%3F"

= is replaced by "%3D"

Why is this happening and how can I fix it?

Laxman13
  • 5,226
  • 3
  • 23
  • 27
Mamadou
  • 2,177
  • 5
  • 31
  • 43
  • That is by design and necessary, it's called URL encoding. Why is it a problem? – Pekka Jun 08 '11 at 10:00
  • This question is basically a duplicate of http://stackoverflow.com/questions/6278135/i-want-to-use-the-question-mark-in-the-auto-generated-path-aliases, just for a start. – Grayside Jun 09 '11 at 07:25

2 Answers2

1

Change it to: 'admin/content/edit-salons-products-services/.$row[salon_id]'.

You can access the salon id with arg(3).

You may also need to change your module's menu declaration to allow this URL.

Finbarr
  • 31,350
  • 13
  • 63
  • 94
  • thank u finbarr, so I ask u a 2nd question : How to check by default deme checboxes in drupal fapi checkboxes – Mamadou Jun 08 '11 at 12:54
  • 1
    @Mamadou If you have a separate question, you should create a new question instead of asking in this one – Laxman13 Jun 08 '11 at 14:02
1

As Finbarr said, it's often better to pass variables as path components, rather than query parameters, but query parameters are still possible with l().

Query parameters are passed into l() outside the base $path, in the $options parameter. This makes it easier to programmatically alter query values, without needing to parse a string. What you want is something like this:

l(t($row['salon_name']),'admin/content/edit-salons-products-services', array('query' => array('side' => $row['salon_id'])));
Scott Reynen
  • 3,530
  • 18
  • 17
  • Since this question is a duplicate, just thought I'd link my roughly equivalent answer: http://stackoverflow.com/questions/6278135/i-want-to-use-the-question-mark-in-the-auto-generated-path-aliases/6289405#6289405 – Grayside Jun 13 '11 at 06:29
  • This is definitely the best approach. – Christian Oct 10 '13 at 02:23