Hi,
I would like to make a link with the l api :
l($text,$path);
But $path is sanitized and the link doesn't works.
Even if it is a l api issue, do you have a idea how I can figure out ?
Thx
Ben

Comments

spouilly’s picture

I am having a similar issue.

I can use prepopulate with OG to prepopulate the group audience of a post. The url for such effect is:

node/add/my-group-content-type?edit[group_audience][und]=NN

Where NN is the group ID of the group I am targeting.
I tested manually, and if I enter the URL in the browser ... everything is fine. The issue is that I am generating some links in a module, and following Drupal's best practises, I use the l() function, and the ?part must be in the 'query'.

$link = l(
  'Add Group Content',
  'node/add/my-group-content',
  array(
    'query' => array('edit[group-audience][und]' => 'NN'),
  )
);

And this generate something like:

http://localhost/node/add/my-group-content?edit%5Bgroup-audience%5D%5Bund%5D=11

You will immediatly notice that the "[" and "]" have been "sanitized", and I do not see any option allowing to bypass such process (FYI it is happeing in drupal_http_build_query() which is called by url()).

So I have ressorted to write raw url (i.e not to use the l() function for that purpose), but if someone has found a way to use l() properly with prepopulate, I would be more than happy to learn from him/her.

Cheers,

S.

koppie’s picture

Status: Active » Fixed

I was also trying to make links to create content inside an OG. I just used html with a token:
<a href="/node/add/event?edit[group_audience][und]=!1">Add a new event</a>
That may not be "Drupal best practices," but it works. At least for OG content creation links, it seems like we're in a bit of a Twilight Zone right now - there was a feature for OG 6.x that was lost in the transition to OG 7.1. 7.2 includes this feature (at least as an add-on module) but OG 7.2 isn't production ready yet.

Given that there is no pre-supplied solution, I think "best practices" in this case is whatever actually works. If you can get it to work as a Drupal API query, more power to you.

I'm marking as "fixed" since we seem to have a workable solution; feel free to reopen if you're not satisfied.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.