Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Test for presence of module or fields


Go to End


3 Posts   1842 Views

Avatar
vwd

Community Member, 166 Posts

2 November 2011 at 2:06pm

Hi,

Is there a conventional way of testing for the presence of Module or specific fields that a module might create?

Thanks very much.

VWD.

Avatar
Howard

Community Member, 215 Posts

2 November 2011 at 9:43pm

You can check if a class exists by doing this:

if (class_exists('MyClass')) {
    $myclass = new MyClass();
}

So you could check for a known class in the module and then assume that the module is installed - maybe not ideal...

Avatar
vwd

Community Member, 166 Posts

3 November 2011 at 11:27am

Thanks @Howard, that'll do the trick.

So there isn't a Sapphire API to test for the presence of a module or widget?

Thanks again.

VWD