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.

General Questions /

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

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

Test for presence of module or fields


Reply


3 Posts   885 Views

Avatar
vwd

Community Member, 160 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, 160 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