Jump to:

17452 Posts in 4473 Topics by 1971 members


SilverStripe Forums » Archive » Detecting module exists

Our old forums are still available as a read-only archive.

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

Page: 1
Go to End
Author Topic: 1401 Views
  • Sigurd
    Forum Moderator
    628 Posts

    Detecting module exists Link to this post

    Some of the code requires knowing if a module has been loaded or not.

    For instance, soon the forum module will need to ask

    If ( google-mapping-module-installed ) {

    Hayden, can you please add this system?

    a) Consult Sam to see about this thinking on it
    b) Note that Andrew is working on related code that only loads modules if a _config.php exists See my top post at http://www.silverstripe.com/core-team-discussion/flat/1202/

  • Sam
    679 Posts

    Re: Detecting module exists Link to this post

    Simplest solution here is to use class_exists, on the relevant class within that module.

    For example:

    if(class_exists('GoogleMapField')) {
    $fields->addFieldToTab(new GoogleMapField());
    } else {
    $fields->addFieldToTab(new TextField());

  • Ingo
    Forum Moderator
    801 Posts

    Re: Detecting module exists Link to this post

    now that we (and external developers) start building modules/plugins, we should think about setting up a basic plugin architecture with hooks into core functionality. some reasons:
    - module developers are not dependent on core changes if the right hooks are existing (e.g. to add cmsfields to the standard page-object)
    - API changes in module/core don't impact each other heavily
    - module developers can release updates independently of the core release cycle
    - the core stays cleaner and is easier to debug

    we need to think on a broader level here, because we're laying the foundations for future module development. if we just write ad-hoc solutions (hacks?) into sapphire/cms, it just creates more problems on the long run.

    matt had some thoughts on this as well, and it might fall in the scope of his GSOC project (mashups).

Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.