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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Get info from another module table


Go to End


2 Posts   1892 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, 5523 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.