xen:link - how to use in an addon?

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:
PHP:
<xen:foreach loop="$garage" value="$test">
{xen:raw $test.garage_id} / {xen:raw $test.name}
{xen:link 'full:garage', $test}
</xen:foreach>

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:
PHP:
        /**
         * @return array
         */
        public function getAllGarages()
        {
            return $this->fetchAllKeyed('
	        SELECT *
            FROM xf_doh_garage_garage
		    ', 'garage_id');
        }

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?
 
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.
 
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.
 
Top Bottom