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   61584 Views

Avatar
UncleCheese

31 March 2009 at 7:37am 4085 Posts

Great catch. I've added that in.

Avatar
hu

31 March 2009 at 8:01am (Last edited: 31 March 2009 8:15am), Community Member, 21 Posts

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

31 March 2009 at 8:15am 4085 Posts

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

31 March 2009 at 8:26am (Last edited: 31 March 2009 8:28am), Community Member, 21 Posts

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

31 March 2009 at 8:31am 4085 Posts

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

31 March 2009 at 8:39am Community Member, 21 Posts

That's right...

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

Avatar
hu

31 March 2009 at 8:59am (Last edited: 31 March 2009 9:00am), Community Member, 21 Posts

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

31 March 2009 at 2:20pm Community Member, 215 Posts

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?