17488 Posts in 4473 Topics by 1978 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1050 Views |
-
Many-many relationship between two page objects

5 October 2008 at 4:04am Last edited: 5 October 2008 7:29am
Hello...
I have tour and place page objects. I would like to have on a tour page places appear in order. By clicking on the place one should get to the place page, which shows all tours going through this place.
I was able to establish the many-many relationship between this two page objects by:
Tour.php
class Tour extends Page {
static $many_many = array(
'Places' => 'Place'
);function getCMSFields() {
$fields = parent::getCMSFields();
$placesTablefield = new ManyManyComplexTableField($this,'Places','Place',
array('Name' => 'Name'),'getCMSFields');
//$placesTablefield->setAddTitle('A Place');$fields->addFieldToTab('Root.Content.Places', $placesTablefield);
return $fields;
}
}Place.php
class Place extends Page {
static $db = array(
'Name' => 'Text'
);static $belongs_many_many = array(
'Places' => 'Place'
);
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Content.Main', new TextField('Name'), 'Name');
return $fields;
}}
1) I am using an additional field to show up in the CMS Places tab 'name'. How can I reference the place page name itself?
2) How can I prevent the 'Add' link showing up within the CMS Places Tab?
3) I need to have an additional numeric field in the Tour_Places table which will allow an ORDER BY. Can this be accomplished?
If so, a push in the right direction would be REALLY helpful. Thanks a lot.
-
Re: Many-many relationship between two page objects

14 November 2008 at 6:59am
to answer question #2 (disable the 'add' button), add this line of code after you create the complextablefield:
$yourtable->setPermissions(array('delete', 'edit'));
(i got the answer from http://www.silverstripe.com/website-authors-forum/flat/76012)i'd love to see answers for question #1 and #3 as well.
-Chris
| 1050 Views | ||
|
Page:
1
|
Go to Top |


