Skip to content
This repository has been archived by the owner on Aug 10, 2018. It is now read-only.

Commit

Permalink
update and document GetPages() - let's go with using the column name …
Browse files Browse the repository at this point in the history
…only for now, it will fail if multiple subclasses tables contain the same column name
  • Loading branch information
James Ellis committed Jan 25, 2012
1 parent a5b254f commit cf1cd78
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion code/fields/DisplayAnythingGalleryField.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,15 +215,19 @@ protected function ControllerIsSiteTree() {
* @note if the controller is a SiteTree then return all pages associated with it
* @param $id the gallery id
* @param $raw if TRUE return as a DataObjectSet else return an array or boolean FALSE on error
* @todo the DataObject::get($class, $name = $id) needs to be looked at:
1. what happens with multiple tables that contain the same column name ?
2. using "`Page`.`{$name}` = " . $id assumes the gallery is attached to Page
3. using "`{$class}`.`{$name}` = " . $id assumes that the controller class contains the column and not a parent class
*/
protected function GetPages($id, $raw = FALSE) {
$list = FALSE;
if($id > 0 && $this->ControllerIsSiteTree()) {
$class = get_class($this->controller);
$current = $this->controller->ID;
$name = $this->name . "ID";
$pages = DataObject::get($class, "`{$name}` = " . $id);
//$pages = DataObject::get($class, "`{$class}`.`{$name}` = " . $id);
$pages = DataObject::get($class, "`Page`.`{$name}` = " . $id);
if($pages) {
if($raw) {
return $pages;
Expand Down

0 comments on commit cf1cd78

Please sign in to comment.