• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

{xen:link} array as an extra param

Despair

Active member
#1
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.
 

Despair

Active member
#3
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:
 
F

Floris

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

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

??
 

Despair

Active member
#5
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