Quote from: Machiavelli at Apr 27, 2006, 12:05 PM
Sorry to keep pestering you with this OpenGeek, but I have another little problem I need your help with.
I have a table in which the the index is called ’id’ ... I’ve set the ActionFieldName, and the CellAction with the idea that it would open up another page showing all of the associated details with that record. The link that is generated ends up being "index.php?id=24&id=18" I tried giving the field an alias (’rfi’), but the generated link always ends up failing. I was hoping for "index.php?id=25&rfi=18"
Will I have to change the field name in the db or is there another way to approach this?
Ah yes, since id is used by MODx URLs to identify the document id (when not using Friendly URLs), this can also cause some problems. This is easy to address by setting the name of the array field that holds the id column value to something unique. Consider a function to build the array (in this case I have a class with all these functions that I load in my snippets)...
<?php
function getIndustries() {
$query= "SELECT COUNT(id) FROM industries";
$this->numRecords= $this->db->getValue($query);
$results= false;
$query= "SELECT i.*, COUNT(DISTINCT aoe.id) AS area_count FROM industries i LEFT JOIN areas_of_expertise aoe ON aoe.industry_id = i.id GROUP BY i.id" . $this->handleSorting() . $this->handlePaging();
if ($ds= $this->db->query($query)) {
while ($row= $this->db->getRow($ds)) {
$results[]= array(
'industry_id'=> $row['id'],
'name'=> stripslashes($row['name']),
'description'=> stripslashes($row['description']),
'area_count'=> $row['area_count'],
);
}
}
return $results;
}
?>
Then I can use this to still sort on the proper actual column value when setting the headers...
<?php
...
$industries= $objExtranet->getIndustries();
$industryTableHeader= array(
'industry_id'=> $objTable->prepareOrderByLink('id', 'IndustryID'),
'name'=> $objTable->prepareOrderByLink('name', 'Name'),
'description'=> $objTable->prepareOrderByLink('description', 'Description'),
'area_count'=> $objTable->prepareOrderByLink('area_count', 'Areas of Expertise'),
'is_core'=> $objTable->prepareOrderByLink('is_core', 'Is Core?'),
);
$objTable->setActionFieldName('industry_id');
...
?>
Hope that helps you out...