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

xen:link - how to use in an addon?

Discussion in 'XenForo Development Discussions' started by dmnkhhn, Oct 9, 2010.

  1. dmnkhhn

    dmnkhhn Active Member

    How can I use {xen:link ...} in my custom addon?

    Inside a foreach I would like to link to a specific garage.

    I currently have this:
    <xen:foreach loop="$garagevalue="$test">
    xen:raw $test.garage_id} / {xen:raw $test.name}
    xen:link 'full:garage'$test}
    hoping that the link helper is smart enough to append the garage_id but all I get is http://localhost/xenforo1b1/garage/

    $garage is filled by this method:
             * @return array
    public function getAllGarages()
                SELECT *
                FROM xf_doh_garage_garage
    I know that this helper takes 4 arguments:
    1. @param string $type Type of data to link to. May also include a specific action.
    2. @param mixed $data Primary data about this link
    3. @param array $extraParams Extra named params. Unhandled params will become the query string
    4. @param callback|false $escapeCallback Callback method for escaping the link
    I only need the first two arguments, the first one seems to be correct but what does the second one expect?
  2. g0rn

    g0rn Well-Known Member

    You need to implement buildLink method in your router prefix class. It should not be hard to do that in your case, actually everything you need to do is just call XenForo_Link::buildBasicLinkWithIntegerParam with correct arguments. Check XenForo's prefix files for examples.
  3. dmnkhhn

    dmnkhhn Active Member

    Amazing, it works! Thanks a ton. :)

    I have noticed that function but there were too many arguments and I didn't know what to do.

Share This Page