{xen:link} array as an extra param

Despair

Active member
If I try this I'll get an error:
Code:
<a href="{xen:link 'path/here', $user, 'a[]={$b}'}">Link</a>

Is there any way to set an array as a param in xen:link? Or would I have to result to doing something like:
Code:
<a href="{xen:link 'path/here', $user}?a[]={$b}">Link</a>

Thanks.
 
Untested, but I think this should work:
{xen:link x, $user, {xen:array 'a={xen:array "0=b"}'}}
 
Ah, should have thought of that, but that throws me an error, I think you don't need the outer array so this works:
Code:
{xen:link x, $user, 'a={xen:array "0=b"}'}

And will give me "path/?a[0]=b". It would also be nice if I could create the array without the key like "path/?a[]=b", but I suppose I can live with it. :cool:
 
buildPublicLink('threads', $thread, array('page' => 2, 'other_param' => 'something))

{xen:link threads, $thread, array('0' => 2, 'other_param' => 'something')}

??
 
Oh I noticed that you can't use a variable as a parameter key for xen:array.

This works:
Code:
{xen:link x, $user, 'a={xen:array "0={$var}"}'}

But not:
Code:
{xen:link x, $user, 'a={xen:array "{$var}=1"}'}

If I want to use a variable as the key I guess I'll have to do like below and use buildPublicLink and send the URL to the template instead?

buildPublicLink('threads', $thread, array('page' => 2, 'other_param' => 'something))

{xen:link threads, $thread, array('0' => 2, 'other_param' => 'something')}

??
Yea figured that out. :) Except that you used PHP syntax within the template syntax. :p
 
Top Bottom