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.

Data Model Questions /

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

Linking DataObjects as Pages


Go to End


10 Posts   4048 Views

Avatar
CodeFade

Community Member, 12 Posts

11 July 2015 at 2:48am

Do you mean I would create Tender.php (DataObject, has_one TenderList), TenderList.php (Controller, has_many Tender), SingleTender.php/SingleTender.ss and SingleTender_show.ss ?

Then I'll create pages Active and Archived, that manually fetches old and new tenders?

In that case where should the Link() function and show() function be placed? Could you give me some code samples?

Avatar
Pyromanik

Community Member, 419 Posts

14 July 2015 at 9:26pm

It seems like you're a bit confused on the role of controllers.
You'd create
Tender.php (DataObject, has_one TenderList)
TenderList.php (Page, has_many Tender)
TenderList.php (Page_Controller, allowed_action show())
TenderList.ss (lists all tenders)
TenderList_show.ss (shows a single tender)

That should about do it.
In the CMS create an 'Archived Tenders' page, and an 'Active Tenders' page.
Then all that's left is to be able to change a tender between the two (so don't hide the has_one 'TenderList' relation from the EditForm)

Go to Top