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

ImageDataObjectManager Display Question


Go to End
Reply

11 Posts   1620 Views

Avatar
Liam

7 October 2010 at 5:37pm Community Member, 470 Posts

I've successfully setup imagedataobjectmanager to manage my images on a dataobject for use in a basic lightbox setup. I've added in the title field to give each image a title. The following code works perfectly with how I've setup my database:

<% control Photos %>
<a href="$Photo.URL" <% if Title %> title="$Title" <% end_if %>">$Photo.CroppedImage(110,110)</a>         
<% end_control %>

I don't think you need the other code, as it works fine.

My question is, right now it links to the full size image that is uploaded via $Photo.URL. I'd like to link to a resized image in case the original image the client uploads in the CMS is too large.

Is the best case to subclass the image class or am I missing something obvious? I tried nesting the Photo control within the href, but that produced errors.

Avatar
UncleCheese

8 October 2010 at 2:52am 4085 Posts

How about..

href="$Photo.SetWidth(800).URL"

--------------------
SilverStripe tips, tutorials, screencasts and more: http://www.leftandmain.com

Avatar
Liam

8 October 2010 at 4:03am Community Member, 470 Posts

I tried that as well, but it returns the full <img> tag to the resized image in its place. It seems to be ignoring the .URL call.

I tried using .Link as well just to test, but still nothing.

Avatar
UncleCheese

8 October 2010 at 4:19am 4085 Posts

Might be one too many levels of dot syntax..

<% control Photo %><% control SetWidth(800) %>$URL<% end_control %><% end_control %>

That's the ridiculously verbose, but surefire way to do it. :)

--------------------
SilverStripe tips, tutorials, screencasts and more: http://www.leftandmain.com

Avatar
Liam

8 October 2010 at 4:27am Community Member, 470 Posts

Perfect. That works.

Funny I tried something along those lines last night, but it produced an error. It was also after midnight, so I probably wasn't thinking clearly and missed something obvious.

Cheers buddy!

Avatar
Liam

8 October 2010 at 5:57am Community Member, 470 Posts

Okay, one last quick question.

I'm trying to limit the total number of uploads by using the below in my getcmsfields function on page.

      if ($this->Photos()->Count() > 4){
         $manager->removePermission('add');
      }

This works, except the add button still display. Just clicking on it, brings up a blank lightbox with no option to upload anything.

Shouldn't this be removing the the add button all together?

Avatar
UncleCheese

8 October 2010 at 7:00am 4085 Posts

Might want to try removePermission('upload');

--------------------
SilverStripe tips, tutorials, screencasts and more: http://www.leftandmain.com

Avatar
Liam

8 October 2010 at 8:24am Community Member, 470 Posts

That removes it, but now I'm left with this html in its place:

<div class="dataobjectmanager-actions ">      
   <h3>Photoss</h3>
</div>

I'm assuming this is the plural listing of the source.

Go to Top