smartysmarty3

Is it possible to check if a (variable) modifier (function) is defined?


I'm using an addon with a smarty templating engine.

In this addon there is this function fn_csc_universal_cdn_convert_font_url, Which can be used inside a template as $variable|fn_csc_universal_cdn_convert_font_url

When I disable the mod the function call is still behind the pipe. Is it possible to check if the function is defined / already exists?

I want to achieve something like this:

{if 'fn_csc_universal_cdn_convert_font_url' is defined}
    $variable|fn_csc_universal_cdn_convert_font_url
{else}
    $variable
{/if}

Solution

  • So far, it doesn't seem possible.

    We've found some workaround for it though.

    By checking if the addon is activated/disabled in the Registry like this:

    if (Registry::get('addons.csc_universal_cdn.status') == "A" )
    { 
        /* ... code to load a dummy replacement function ... */ 
    }
    

    This code was both updated in the addon as in our own my_changes addon. By doing this there is always a function defined whether the addon is activated or not.