XF 2.0 Checking addon enabled in template

[F.A] Walky

Active member
Hello,

I’d like to check if an addon is enabled in template. I’ve seen the $xf variable contains an array with addOns which contains all the enabled addon.

But when an addon as an ID containing a « / », such as: ForoAgency/AddOn, we can’t access it in template like: $xf.addOns.ForoAgency/AddOn:(

Is there a way to achieve this like that ?

Best regards,
Walky
 
Code:
<xf:set var="$addOnId">ForoAgency/AddOn</xf:set>
<xf:if is="{$xf.addOns.{$addOnId}}">
    Add-on is enabed
</xf:if>
Should work
 
Code:
<xf:set var="$addOnId">ForoAgency/AddOn</xf:set>
<xf:if is="{$xf.addOns.{$addOnId}}">
    Add-on is enabed
</xf:if>
Should work
Template is saved successfully, but when I go on the page I got this :
  • Template public:fa_sh.index: Illegal offset type (internal_data\code_cache\templates\l1\s1\public\fa_sh.index.php:31)
 
When I was replying, I was 99% sure we had added something else which would work. I couldn't remember what it was or where it was added. Just found it :)

Code:
<xf:if is="is_addon_active('ForoAgency/AddOn')">
    Add-on is enabled
</xf:if>

You can also do version comparison checks:

Code:
<xf:if is="is_addon_active('ForoAgency/AddOn', 2000070)">
    Installed version is >= 2000070
</xf:if>

Or use a different comparison operator:

Code:
<xf:if is="is_addon_active('ForoAgency/AddOn', 2000070, '<')">
    Installed version is < 2000070
</xf:if>
 
When I was replying, I was 99% sure we had added something else which would work. I couldn't remember what it was or where it was added. Just found it :)

Code:
<xf:if is="is_addon_active('ForoAgency/AddOn')">
    Add-on is enabled
</xf:if>

You can also do version comparison checks:

Code:
<xf:if is="is_addon_active('ForoAgency/AddOn', 2000070)">
    Installed version is >= 2000070
</xf:if>

Or use a different comparison operator:

Code:
<xf:if is="is_addon_active('ForoAgency/AddOn', 2000070, '<')">
    Installed version is < 2000070
</xf:if>
Wow, awesome, much better than the other trick ! :)
 
Yeah that's why we implemented it. It may have been only recently, perhaps in 2.0.2 or 2.0.1. But it was certainly much better than the original approach, I must have just forgotten :ROFLMAO:
 
Top Bottom