1. 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

Discussion in 'XenForo Development Discussions' started by Despair, Nov 24, 2011.

  1. Despair

    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.
     
  2. Mike

    Mike XenForo Developer Staff Member

    Untested, but I think this should work:
    {xen:link x, $user, {xen:array 'a={xen:array "0=b"}'}}
     
    Despair likes this.
  3. Despair

    Despair Active Member

    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:
     
  4. Floris

    Floris Guest

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

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

    ??
     
  5. Despair

    Despair Active Member

    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?

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

Share This Page