3063 Posts in 864 Topics by 646 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1182 Views |
-
Paging a $many_many DataObjectSet

12 February 2010 at 3:27pm Last edited: 12 February 2010 5:19pm
Hi, I have a couple of related pagetypes which I need to draw dataObjectSets from and paginate the results:
BrandCategoryPage.php
class BrandCategoryPage extends Page {
static $many_many = array('BrandPages' => 'BrandPage');
}function getCMSFields() {
$f = parent::getCMSFields();$areasTablefield = new ManyManyComplexTableField(
$this,
'BrandPages',
'BrandPage',
array(
'Title' => 'Title'
),
'getCMSFields_forPopup'
);
$areasTablefield->setAddTitle( 'Brands' );
$f->addFieldToTab( 'Root.Content.Brands', $areasTablefield );
return $f;
}and BrandPage.php
class BrandPage extends Page {
static $has_one = array(
'Logo' => 'Image'
);static $belongs_many_many = array(
"BrandCategoryPages" => "BrandCategoryPage"
);function getCMSFields() {
$f = parent::getCMSFields();
$f->addFieldToTab("Root.Content.Images", new ImageField('Logo'));
return $f;
}what i wanted to do was something like this:
function BrandPages_Paged() {
if(!isset($_GET['start']) || !is_numeric($_GET['start']) || (int)$_GET['start'] < 1) $_GET['start'] = 0;
$SQL_start = (int)$_GET['start'];
$doSet = DataObject::get(
$callerClass = "BrandPage",
$filter = "BrandCategoryID=$this->ID",
$sort = "",
$join = "",
$limit = "{$SQL_start},2"
);return $doSet ? $doSet : false;
}but this throws errors....
Anyone know how I can relate back to the category this way?
Cheers
-
Re: Paging a $many_many DataObjectSet

15 February 2010 at 12:48pm
You missed some backticks:
$filter = "`BrandCategoryID`=$this->ID"
| 1182 Views | ||
|
Page:
1
|
Go to Top |

