My add-on has a global permission to view the template which is on the forum index.
Talking to a couple of developers about this and was interested to see each had a different preferred way of doing it: extend the controller, or via a simple <xen:if is="{$visitor.permissions.(permission group ID).(permission ID}"> check in the template.
Unless I am completely misunderstanding things (which is very likely), I can't see any benefit at all in extending the controller for the global perm.
Doing it in the template it's a simple xen:if, e.g. <xen:if is="{$visitor.permissions.ctaFt.ctaFtViewFeaturedThreads}">
Doing it the other way however involves creating a new ControllerPublic\Forum.php to extend XenForo\ControllerPublic\Forum.php.
In addition, the model needs to have a new public function canViewFeaturedThreads, which also requires a corresponding <xen:if is="{$canViewFeaturedThreads}"> on the template anyway.
So the amount of template code is more or less the same but the second way involves much more php code.
How do others do it and why have you done it that way?
Talking to a couple of developers about this and was interested to see each had a different preferred way of doing it: extend the controller, or via a simple <xen:if is="{$visitor.permissions.(permission group ID).(permission ID}"> check in the template.
Unless I am completely misunderstanding things (which is very likely), I can't see any benefit at all in extending the controller for the global perm.
Doing it in the template it's a simple xen:if, e.g. <xen:if is="{$visitor.permissions.ctaFt.ctaFtViewFeaturedThreads}">
Doing it the other way however involves creating a new ControllerPublic\Forum.php to extend XenForo\ControllerPublic\Forum.php.
In addition, the model needs to have a new public function canViewFeaturedThreads, which also requires a corresponding <xen:if is="{$canViewFeaturedThreads}"> on the template anyway.
So the amount of template code is more or less the same but the second way involves much more php code.
How do others do it and why have you done it that way?