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

Adding Files to Images within Image Gallery


Go to End
Reply


21 Posts   3964 Views

Avatar
go2planC

Community Member, 19 Posts

27 October 2009 at 12:26pm

Edited: 27/10/2009 12:58pm

Hi Uncle Cheese,

First I'd like to say wicked job with the image gallery and DataObject Modules. 5 Star!!!!!

Ok here's my problem, I'm currently building a site that the image gallery works perfectly for except what I need to do is to add files to each image. For Example I've got a normal gallery image, but I would like to attach multiple files such as photoshop version of it to the gallery image for the end user to download.

Is this posible? I've been banging my head against the desk for days now and finally had to give and ask for help. So please help.

Cheers

Avatar
UncleCheese

Forum Moderator, 4096 Posts

28 October 2009 at 3:08am

Easiest thing to do..

Create a subclass of ImageGalleryPage

MyImageGalleryPage extends ImageGalleryPage

protected $itemClass = "MyImageGalleryItem";

MyImageGalleryItem extends ImageGalleryItem
// define a has_one to your file
function getCMSFields_forPopup()
{
$f = parent::getCMSFields_forPoup();
// add file field
return $f;
}

Avatar
zaighum47

Community Member, 3 Posts

5 June 2010 at 7:32pm

I want to do the same thing, but cannot fully grasp what UncleCheese has said. If possible could it be explained in more detail? or perhaps an alternative way. Thanks in Advance

Avatar
UncleCheese

Forum Moderator, 4096 Posts

6 June 2010 at 3:34am

You just need to subclass your ImageGalleryPage and ImageGalleryItem classes so you can customise them.

MyImageGalleryPage extends ImageGalleryPage

protected $itemClass = "MyImageGalleryItem";

MyImageGalleryItem extends ImageGalleryItem

static $has_one = array ('SomeFile' => 'File');

function getCMSFields_forPopup()
{
$f = parent::getCMSFields_forPoup();
$f->push(new FileIFrameField('SomeFile');
return $f;
}

Avatar
zaighum47

Community Member, 3 Posts

11 June 2010 at 10:24pm

Thank you UncleCheese,
I did the following.
1. Created a file -> MyImageGalleryPage.php in mysite/code with:

<?php
class MyImageGalleryPage extends ImageGalleryPage{
protected $itemClass = "MyImageGalleryItem";
}
class MyImageGalleryPage_Controller extends ImageGalleryPage_Controller {

}
?>


2. Created a file -> MyImageGalleryItem.php in mysite/code with:

<?php
class MyImageGalleryItem extends ImageGalleryItem {
static $has_one = array ('ABC' => 'File');

function getCMSFields_forPopup()
{
$f = parent::getCMSFields_forPopup();
$f->push(new FileIFrameField('ABC'));
return $f;
}
}
?>


I get some error the first time I upload a picture in the field where I should attach another file. But if I just ignore it, save the file, then open it up again, it seems to work fine.
The problem is it doesn't show up on the slideshow anywhere with any of the configuration. I tried the same thing but with just adding another caption-> same thing will not show up on the slideshow.
Is there anything else I should do? or did wrong?
THANKS UNCLECHEESE! =]

The error btw is:

[Notice] Undefined index: uploaded_files
GET /admin/EditForm/field/GalleryItems/EditUploadedForm/field/ABC/iframe?ctf[GalleryItems][start]=0&ctf[GalleryItems][per_page]=10&ctf[GalleryItems][showall]=0&ctf[GalleryItems][sort]=SortOrder&ctf[GalleryItems][sort_dir]=DESC&ctf[GalleryItems][search]=&ctf[GalleryItems][filter]=AlbumID_8&ctf[GalleryItems][view]=grid&ctf[GalleryItems][imagesize]=100

Line 393 in C:\wamp\www\dataobject_manager\code\FileDataObjectManager.php
....
393       $total = isset($_POST['totalsize']) ? $_POST['totalsize'] : sizeof($_POST['uploaded_files']);
....

Trace

* FileDataObjectManager->EditUploadedForm(SS_HTTPRequest)
Line 134 of RequestHandler.php
* RequestHandler->handleRequest(SS_HTTPRequest)
Line 152 of RequestHandler.php
* RequestHandler->handleRequest(SS_HTTPRequest)
Line 152 of RequestHandler.php
* RequestHandler->handleRequest(SS_HTTPRequest)
Line 147 of Controller.php
* Controller->handleRequest(SS_HTTPRequest)
Line 283 of Director.php
* Director::handleRequest(SS_HTTPRequest,Session)
Line 127 of Director.php
* Director::direct(/admin/EditForm/field/GalleryItems/EditUploadedForm/field/ABC/iframe)
Line 127 of main.php

Avatar
zaighum47

Community Member, 3 Posts

2 July 2010 at 3:13pm

Bump. =[

Avatar
mattclegg

Community Member, 56 Posts

3 August 2010 at 12:35am

Edited: 05/09/2010 1:55pm

I think the problem might be occurring because the post variables are not being passed to the inside of an iFrame.

Try changing Line 493 of FileDataObjectManager.php to something like;

if(isset($_POST['totalsize']))
   $total = $_POST['totalsize'];
elseif(isset($_REQUEST['uploaded_files']))
   $total = sizeof($_REQUEST['uploaded_files']);
else
   $total = 1; //Hardcode for iFrame

Avatar
adesweb

Community Member, 39 Posts

3 September 2010 at 3:12am

Hi,

Had the same issue. This works, but the first time I upload, and then try and upload the thumbnail in the imageField, I get the following error:

Fatal error: Call to a member function write() on a non-object in /home/adrianw/PROJECTS/bcl/website2009/sapphire/forms/FileIFrameField.php on line 209

Please can someone help?

Adrian

Go to Top