Question

I have written a module that uses vqmod for opencart. How can I check if vqmod is installed from within the admin module?

I would like to display a warning inside of the module that checks if vqmod is installed? Even better would be to check if it also has correct write permission to generate cached files and write to the vamod.log

What is the best way of doing this?

PS: it would be cool if you could tag questions with vqmod. I dont have enough reputation to create a new tag.

Était-ce utile?

La solution

<?php
    if(class_exists('VQMod')) {
         // vqmod exists
    }
?>

Autres conseils

/vqmod/install

if it is installed it will tell you "vqmod is already installed"

To check via code, you would need to do

global $vqmod;
if(!empty($vqmod) && is_a($vqmod, 'VQMod')) {
    // INSTALLED
} else {
    //
}

While @NADH's is along the right lines, it only checks that vqmod's class has been included, not that it's been set to the $vqmod variable

Edit

As of 2.4.0, this will no longer work, and it's recommended to use NADH's method

Based on your comments @John, since you're looking for confirmation that VQmod is installed and also executing correctly, the safest thing to do to is check for the filename you are expecting to appear in the vqmod/cache directory. You'll know the filename if you have created the vqmod/xml definition file yourself.

You could also check for the VQMod class existing like @NADH suggested, but it doesn't mean that its working correctly. A bit like writing unit tests, always assert on the desired output. In this case its' the cache file you are creating.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top