XF 2.0 How to build canonical link to an admin route

Sim

Well-known member
How can I generate a canonical link to an admin route using a template function in an email template?

For example, in an admin template, {{ link('canonical:tools') }} generates the expected http://example.com/admin.php?tools/

However, in an email template, it assumes a public route and generates: http://example.com/index.php?tools

How can I force it to generate an admin link?
 
Not sure about in public/email templates, but you can use \XF::app()->router('admin')->buildLink('tools') to generate the link and use that as a parameter in your email
 
Not sure about in public/email templates, but you can use \XF::app()->router('admin')->buildLink('tools') to generate the link and use that as a parameter in your email

Yes, that's what I'm doing now - but it would be nice to have a template function which avoids the need to do that for email templates.
 
Yes, that's what I'm doing now - but it would be nice to have a template function which avoids the need to do that for email templates.

Actually, have a look at the "actions" dropdown on the edit user page, there is a link to view public profile there from an admin template. Might be able to do something similar to get an admin link from a public/email template. Don't have an install anywhere near me right now just happened to think of this while on mobile
 
  • Like
Reactions: Sim
Actually, have a look at the "actions" dropdown on the edit user page, there is a link to view public profile there from an admin template. Might be able to do something similar to get an admin link from a public/email template. Don't have an install anywhere near me right now just happened to think of this while on mobile

That's exactly what I'm looking for - thanks!

{{ link_type('admin', 'tools') }} works as expected in an email template.
 
Back
Top Bottom