Check for Vendor in Backend .tpl files

Hi,



I'm trying to find a way to check for vendor page in the backend.



I.e. how to tell if the user is in admin backend or vendor backend?



Any help would be much appeciated

What version are you running? In V3, you would simply use (php)


if( defined("COMPANY_ID") )


In template code you would just use


{if $smarty.const.COMPANY_ID}


Not sure about MVE in V4 (haven't looked). But for all versions you could probably do:


if( strpos("vendor.php", $_SERVER['REQUEST_URI']) ) // php code
{if "vendor.php"|strpos:$smarty.server.REQUEST_URI} {* tpl syntax *}

Cheers @tbirnseth you led me onto the right path. I actually used the following code:


{if $smarty.server.REQUEST_URI|strstr:"vendor.php"} 
    VENDOR
{else}
    ADMIN
{/if}



  • Edited for readability:



    {if $smarty.server.REQUEST_URI|strstr:“vendor.php”}

    MULTIVENDOR

    {else}

    ADMIN

    {/if}

While that works, it does make you dependent upon a name that can be changed in config.local.php for MVE which is not good. To be robust, you should change “vendor.php” to use $config.vendor_index.

cheers @tbirnseth … have taken on your suggestion :)