7921 Posts in 1359 Topics by 933 members
DataObjectManager Module
SilverStripe Forums » DataObjectManager Module » Preview: DataObjectManager module
Discuss the DataObjectManager module, and the related ImageGallery module.
Moderators: martimiz, UncleCheese, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
| Go to End | Next > | |
| Author | Topic: | 54670 Views |
-
Re: Preview: DataObjectManager module

30 March 2009 at 7:31am Last edited: 30 March 2009 7:32am
@howard - This was a tricky one. Undo your changes and check out the latest version to get a functional setColumnWidths() function. It can be used exactly has you built it:
$manager->setColumnWidths(array(
'Name' => 20,
'Description' => 60,
'Category' => 20
));I believe it works best when you pass the values as integers. Make sure they add up to 100. I'll add the error checking later.
The trick to getting the individual items to draw their widths was to tap into the Fields array of the DataObjectManager_Item class. I actually ended up overloading the Fields() method inherited from TableListField to accomplish this.
Looks good so far. Please test and let me know what you think.
@tsunami - Please refer to the documentation in the SS Wiki first, and then write a detailed explanation of the problem you're having so one of us can help you out.
-
Re: Preview: DataObjectManager module

30 March 2009 at 9:07am
Yea that's brilliant, working well! I tried overloading the Fields method but somehow stuffed it up - your solution looks better
I will keep testing, the to-do list looks good - I can't think of anything else to add at the moment.
Thanks once again.
-
Re: Preview: DataObjectManager module

30 March 2009 at 11:35am Last edited: 30 March 2009 11:37am
@unclecheese - hi, sorry I know stupid questions must waste your time, but I had been through the wiki stuff and still couldn't get it to work. I've sorted it now after a bit of trial and error, and it works for my purposes but there may be a more elegant way to do it...so I'll post it ..it may help someone else.
what I had was a series of images using ImageDataObjectManager that needed to have a common identifier , so I wanted to use the parent pageID (because there are multiple child pages output on a pageholder)...the page uses jquery cycle and prettyphoto.
I ended up with:
####TreeImage.php####
class TreeImage extends DataObject
{
static $db = array (
'TreeImageCaption' => 'Text',
);
static $has_one = array (
'TreeImageFile' => 'Image',
'TreePage' => 'TreePage'
);
public function getCMSFields_forPopup()
{
return new FieldSet(
new TextField('TreeImageCaption'),
new ImageField('TreeImageFile')
);
}
function theparent()
{
$parent = $this->TreePage();
return $parent;
}
}and in TreeHolder.ss
<% control Children %>
........
<% if TreeImages %>
<div class="slider" id="cycle$ID">
<% control TreeImages %>
<a rel="prettyPhoto[$theparent.ID]" title="$TreeImageCaption" href="$TreeImageFile.URL">
<% control TreeImageFile %>
$CroppedImage(240,180)
<% end_control %>
</a>
<% end_control %>
</div>...........
<% end_if %>
..........
<% end_control %>final page is here
-
Re: Preview: DataObjectManager module

30 March 2009 at 12:02pm
Why couldn't you just use $TreePageID?
-
Re: Preview: DataObjectManager module

30 March 2009 at 12:14pm
Yes...thats the more elegant solution I was talking about
-
Re: Preview: DataObjectManager module

31 March 2009 at 7:32am
Uncle Cheese, can you please add this code to DataObjectManager.php.
If you are using get-functions or joined fields in the grid the SQL search string will not execute.protected function loadSourceFilter() {
...
if(!empty($this->search)) {
$search = array();
$SNG = singleton($this->sourceClass);
foreach(parent::Headings() as $field) {
if ($SNG->hasField($field->Name))
$search[] = "UPPER($field->Name) LIKE '%".strtoupper($this->search)."%'";
}
$search_string = "(".implode(" OR ", $search).")";
}
...
} -
Re: Preview: DataObjectManager module

31 March 2009 at 8:01am Last edited: 31 March 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
<% 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>
| 54670 Views | ||
| Go to Top | Next > |

