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.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Get info from another module table


Reply


2 Posts   774 Views

Avatar
ud2013

Community Member, 6 Posts

22 June 2013 at 6:58am

I am building several custom modules, what I would like to know, is it possible to get certain info from a table which belongs to another module? If so, how?

For example:

I have a module (module1) which holds info of a number of companies, now another module (module2) needs certain info from that other module (module1) and use it in the other module (module2). In module1, I wish to use the url of the company. Can I get that url and add it to module2?

Thanks.

Avatar
Willr

Forum Moderator, 5513 Posts

22 June 2013 at 7:29pm

All your websites modules get added to the same database as well as all the classes to the manifest, so yes you can call code which depends on other modules or extend them in particular ways.

So in your example, your module 1 may have a DataObject defined for 'Company' your module 2 can get all those companies by doing $companies = Company::get(); in PHP code. SilverStripe handles finding the correct classes, tables etc for you.