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.

DataObjectManager Module

Discuss the DataObjectManager module, and the related ImageGallery module.

Moderators: martimiz, UncleCheese, Sean, biapar, Willr, Ingo, swaiba, simon_w

Preview: DataObjectManager module


Reply

379 Posts   61751 Views

Avatar
UncleCheese

31 March 2009 at 4:24pm 4085 Posts

Default sort is the 7th (8th in filedataobjectmanager) argument of the field. Check the api on complextablefield.

Avatar
Howard

31 March 2009 at 9:52pm Community Member, 215 Posts

I had a play with that and added 'DESC' which didn't do anything, so I tried 'ASC' then 'Date DESC' etc but nothing made a difference. Is there something that I am doing wrong?

$manager = new DataObjectManager(
   $this, // Controller
   'PlanningComments', // Source name
   'PlanningComment', // Source class
   array('Date' => 'Date', 'Name' => 'Name', 'PlanningComment' => 'Comment'), // Headings
   'getCMSFields_forPopup', // Detail fields function or FieldSet   
   '', // Filter clause
   'DESC', // Sort clause
   ''// Join clause

Avatar
hu

31 March 2009 at 10:06pm Community Member, 21 Posts

Hi Howard,

"Sort clause" means column and sort direction. So you have to select a column. i.e

...
'', // Filter clause
'Date DESC', // Sort clause
''// Join clause
...

But protected function loadSort() {...} in DataObjectManager.php overrides this value to null. So you have to remove this line

protected function loadSort() {
if($this->ShowAll())
$this->setPageSize(999);

if($this->Sortable() && (!isset($_REQUEST['ctf'][$this->Name()]['sort']) || $_REQUEST['ctf'][$this->Name()]['sort'] == "SortOrder")) {
$this->sort = "SortOrder";
$this->sourceSort = "SortOrder ASC";
}
elseif(isset($_REQUEST['ctf'][$this->Name()]['sort']))
$this->sourceSort = $_REQUEST['ctf'][$this->Name()]['sort'] . " " . $this->sort_dir;
else
$this->sourceSort = null;

}

Avatar
Howard

31 March 2009 at 10:34pm Community Member, 215 Posts

Great that worked :) Thanks hu

Avatar
UncleCheese

1 April 2009 at 2:30am 4085 Posts

Shouldn't have to make that change in the latest version.

Avatar
Ben Gribaudo

1 April 2009 at 10:03am Community Member, 181 Posts

Hi,

I'm running revision 103 of DataObjectManager against revision 73881 of trunk. When I click the "save" button on the "add" pop-up window, the object I'm trying to add never gets saved to the database. Instead, I get sent to some kind of page that has an add link and a search box, etc.

The "add" pop-up window's form tag is as follows:
<form id="DataObjectManager_Popup_AddForm" action="admin/EditForm/field/Articles?ctf[Articles][per_page]=10&amp;ctf[Articles][showall]=0&amp;ctf[Articles][sort]=Created&amp;ctf[Articles][sort_dir]=DESC&amp;ctf[Articles][search]=&amp;ctf[Articles][filter]=" method="post" enctype="application/x-www-form-urlencoded">

Is that the correct action? It looks funny to me.

Thanks,
Ben

Avatar
UncleCheese

1 April 2009 at 10:08am 4085 Posts

That's the right link. Can you post a screenshot? Some code?

Avatar
Ben Gribaudo

1 April 2009 at 10:14am Community Member, 181 Posts

Thanks for the fast response! Image (which appears after I click save) & code attached.

Ben

Attached Files