17488 Posts in 4473 Topics by 1978 members
| Go to End | ||
| Author | Topic: | 8979 Views |
-
Re: Many images

18 July 2008 at 6:44am
YOU ARE THE KING.
Thanks you SO much!
Now how about iterating through these in the template?? Is that possible? Seems that I'll need some sort of function which puts the images in a collection of some kind, as these images are not "Children" of the page in the classic sense.
How would you go about that?
Thanks in advance,
Garrett -
Re: Many images

18 July 2008 at 6:51am
<% control PropertyName %>
will iterate through any has_many property of your object.
on ProjectPage.ss:
<% control ImageAttachments %>
$Image
$Title
<% end_control %>I think I mentioned this before, but you probably want to check out the GD functions for your Images..
http://doc.silverstripe.com/doku.php?id=imageupload
Very useful, and I think one of the most powerful features of Silverstripe. Glad that all worked out for you.
-
Re: Many images

18 July 2008 at 7:38am
YES! I suppose that was the whole point of the ImageAttachment class, now, wasn't it ;) You have been a treMENdous help, I cannot thank you enough! My Image Gallery is totally rocking now.
//Garrett
-
Re: Many images

4 September 2008 at 2:33am Last edited: 4 September 2008 2:34am
Hi,
Please help me ...
I am trying to upload multiple images for Product.
while trying to save & publish page through admin i am facing this error ...ERROR:Error 256: Object::__call() Method 'ImageAttachment' not found in class 'Products' At l199 in D:\workspace\projects\silver\sapphire\core\Object.php
Please find the code below ...
Products.php fileclass Products extends Page {
static $db = array(
'Industry' => 'Text',
'Type' => 'Text',
'Serving' => 'Text',
'Info' => 'Text',
'ReviewsBuzz' => 'Text',
'Technology' => 'Text',
'WhatsCooking' => 'Text'
);
static $has_one = array(
'TitleImage' => 'Image',
'ThumbnailImage' => 'Image'
);
static $has_Many = array(
'ImageAttachment' => 'ImageAttachment'
);
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Content.Main', new ImageField('TitleImage', 'Title Image'));
$fields->addFieldToTab('Root.Content.Main', new TextField('Industry','Industry'));
$fields->addFieldToTab('Root.Content.Main', new TextField('Type','Type'));
$fields->addFieldToTab('Root.Content.Main', new TextField('Serving','Serving'));
$fields->addFieldToTab('Root.Content.Main', new TextareaField('Info','Info'));
$fields->addFieldToTab('Root.Content.Main', new TextareaField('ReviewsBuzz','Reviews Buzz'));
$fields->addFieldToTab('Root.Content.Main', new TextareaField('Technology','Technology'));
$fields->addFieldToTab('Root.Content.Main', new TextareaField('WhatsCooking','Whats Cooking'));
$fields->addFieldToTab('Root.Content.Main', new ImageField('ThumbnailImage', 'Screen Shot'));
$fields->removeFieldFromTab("Root.Content.Main","Content");
$imagetable = new HasManyComplexTableField(
$this,
'ImageAttachment', // relation name
'ImageAttachment', // object class
/*array(
'Link' => 'Link',
'ImageID' => 'Image'
),
'getCMSFields_forPopup'*/
ImageAttachment::$field_names, // fields to show in table
ImageAttachment::getCMSFields_forPopup(), // form that pops up for edit
"ProductsID = {$this->ID}" // a filter to only display item associated with this page
);
//$imagetable->setParentClass('Products');
//$imagetable->setAddTitle( 'A Image' );
$fields->addFieldToTab('Root.Content.RightPanelImage', $imagetable);
return $fields;
}
}
class Products_Controller extends Page_Controller{
}ImageAttachment.php File
class ImageAttachment extends DataObject {
static $db = array(
'Link' => 'Text'
);
static $has_one = array(
'Image' => 'Image',
'Products' => 'Products'
);
static $field_names = array('Link' => 'Link');
function getCMSFields_forPopup() {
$fields = new FieldSet();
$fields->push(new TextField('Link', 'Link'));
$fields->push(new ImageField('Image', 'Image'));
return $fields;
}
}Please tell me what i am doing wrong.
-
Re: Many images

4 September 2008 at 2:44am
I'd be happy to help you if you would remove the strikethroughs from your code so I can read it.
Thanks,
Garrett -
Re: Many images

4 September 2008 at 4:54pm
Hi UncleCheese
It Worked .... Thanks
Sorry Garrett .... by mistake i done strikethroughs ...
| 8979 Views | ||
| Go to Top |

