10387 Posts in 2198 Topics by 1712 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 938 Views |
-
Image gallery module

4 June 2010 at 9:51pm
I have uploaded and installed the image gallery module (Uncle cheeses one) / swfupload etc etc .
My request is simple , I need to add another field underneath the "Caption" field called "Info" . Where can I do this ?
Thanks so much in advance !
SimonC
-
Re: Image gallery module

5 June 2010 at 2:21am
class MyImageGalleryPage extends ImageGalleryPage
{
protected $itemClass = "MyImageGalleryItem";
}class MyImageGalleryItem extends ImageGalleryItem
{
static $db = array ('Foo' => 'Text');public function getCMSFields_forPopup()
{
$f = parent::getCMSFields_forPopup();
$f->push(new TextField('Foo'));
return $f;
}
} -
Re: Image gallery module

7 June 2010 at 10:36pm
Thanks uncle cheese for the quick response and also the code
But, Im fairly noob and have no idea what im doing wrong but I cant seem to get it to work ... this is what I have done .
1. Created a new file in imagegallery/code called ImageGalleryField.php
2. Copied the following code in the file :<?php
class MyImageGalleryField extends ImageGalleryPage
{
protected $itemClass = "MyImageGalleryItem";
}class MyImageGalleryItem extends ImageGalleryItem
{
static $db = array ('Foo' => 'Text');public function getCMSFields_forPopup()
{
$f = parent::getCMSFields_forPopup();
$f->push(new TextField('Foo'));
return $f;
}
}class MyImageGalleryField_Controller extends ImageGalleryPage_Controller {
}
?>3. Ran dev/build
4. I am now getting errors ... http://www.pastie.org/994741
Thanks again for your help, and time
Simon C
-
Re: Image gallery module

8 June 2010 at 1:52am
No, no.. Never touch anything in the image_gallery directory. That's the whole point of subclassing -- so you don't have to hack the core code. All of these new files should be in your project directory.
In Silverstripe, your class names have to be the same as the .php file in which they are contained, so "ImageGalleryField.php" and "MyImageGalleryField" isn't going to work.
Just as a side note, it's a little unusual that you've named your subclass of ImageGalleryPage "ImageGalleryField?" You're subclassing the entire page type.. it has nothing to do with a field. Name it something that is relevant to your customization, for instance, if you're going to have a gallery of cars, call it "AutoGallery extends ImageGalleryPage"...
-
Re: Image gallery module

8 June 2010 at 7:58pm
Hi again, thanks for that . I see what you are saying ...
But I am still getting errors .
I have made the file in mysite/code/PetGalleryPage.php
<?php
class PetGalleryPage extends ImageGalleryPage
{
protected $itemClass = "MyImageGalleryItem";
}class MyImageGalleryItem extends ImageGalleryItem
{
static $db = array ('Foo' => 'Text');public function getCMSFields_forPopup()
{
$f = parent::getCMSFields_forPopup();
$f->push(new TextField('Foo'));
return $f;
}
}class PetGalleryPage_Controller extends ImageGalleryPage_Controller {
}
?>then ran dev/build
and get these :http://pastebin.com/6iKE8eGz
I just don't get what could be wrong here....
thanks again
-
Re: Image gallery module

9 June 2010 at 1:55am
Are all those in the same file? The page and its controller should be in one file, but the Item subclass needs to be in its own. Generally, in SS, it's one class per file.
| 938 Views | ||
|
Page:
1
|
Go to Top |

