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.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Preview: DataObjectManager module


Go to End


379 Posts   75653 Views

Avatar
UncleCheese

Forum Moderator, 4102 Posts

31 March 2009 at 7:37am

Great catch. I've added that in.

Avatar
hu

Community Member, 21 Posts

31 March 2009 at 8:01am

Edited: 31/03/2009 8:15am

The same problem occurs with sorting by column.

public function Headings() {
...
	foreach($headings as $heading) {
	...
		$heading->SortLink = $this->RelativeLink(array(
			'sort_dir' => $heading->SortDirection, 
			'sort' => $heading->Name
		));
		$heading->IsSortable = singleton($this->sourceClass)->hasField($heading->Name);
	}
	return $headings;
}

DataObjectManager.ss

<div class="pad">
	<% if IsSortable %>
		<a href="$SortLink">$Title &nbsp;
		<% if IsSorted %>
			<% if SortDirection = ASC %>
			<img src="cms/images/bullet_arrow_up.png" alt="" />
			<% else %>
			<img src="cms/images/bullet_arrow_down.png" alt="" />
			<% end_if %>
		<% end_if %>
		</a>
	<% else %>
	  $Title
	<% end_if %>
</div>

Avatar
UncleCheese

Forum Moderator, 4102 Posts

31 March 2009 at 8:15am

Thanks. I've already started making the update. Only thing I did differently was put the if clause within the <div class="pad">

Avatar
hu

Community Member, 21 Posts

31 March 2009 at 8:26am

Edited: 31/03/2009 8:28am

How about ...?

public function setColumnWidths($widths) {
...
    die('<strong>DataObjectManager::setColumnWidths()</strong>:' . _t('DataObjectManager.TOTALNOT100','Column widths must total 100 and not '.$total));
...
}

I don't like counting...

Avatar
UncleCheese

Forum Moderator, 4102 Posts

31 March 2009 at 8:31am

Yeah, I had that originally, but I don't think it gets along with the _t() function when you have a variable in the translated string.

Avatar
hu

Community Member, 21 Posts

31 March 2009 at 8:39am

That's right...

sprintf(_t('DataObjectManager.TOTALNOT100','Column widths must total 100 and not %s'), $total)

Avatar
hu

Community Member, 21 Posts

31 March 2009 at 8:59am

Edited: 31/03/2009 9:00am

One more ...
If i set $sourceSort in the constructor of DataObjectManager(...) nothing is sorted. Please remove

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

Community Member, 215 Posts

31 March 2009 at 2:20pm

Hi, hopefully an easy question - How can I reverse the default sorting? Currently the oldest object is displayed first but ideally the newest one would be... any ideas?

Go to Top