21278 Posts in 5728 Topics by 2599 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 845 Views |
-
Cannot Reference Banner Image more than Once

3 September 2010 at 4:36am
*** newbie/noob question (sorry) ***
I have extended SiteTree in my Page.php to provide support for banner images on pages within my site - and this works as intended, for example:
class Page extends SiteTree {
public static $db = array(
);public static $has_one = array(
'BannerImage' => 'Page_BannerImage',
);function getCMSFields() {
$fields = parent::getCMSFields();
$fields ->addFieldsToTab(
'Root.Content.Banner',
new ImageField('BannerImage', 'Banner')
);return $fields;
}
function getBannerImageRecursive() {
$page = $this;
$banner = $this->BannerImage();
while(!$banner->ID && $page->ParentID !=0) {
$page = $page->Parent();
$banner = $page->BannerImage();
}return $banner;
}
The obstacle I have encountered is that once an image is selected from the File Store and attached to a page, that image is no longer referenced in the File Store list and cannot (apparently) be used as an attachment for another page. Yes, I know that I can attach an image from my file system (workaround?) yet, I am looking for a method that continues to enumerate the files/images on the File Store list.
Any ideas???
-
Re: Cannot Reference Banner Image more than Once

4 September 2010 at 1:30am Last edited: 4 September 2010 1:30am
I'm also having this problem a lot. I tend to use the Image DataObjectManager instead.
-
Re: Cannot Reference Banner Image more than Once

4 September 2010 at 2:16am
dendeffe - Thanks for the tip on an alternative method! Now, (and since I am a novice here) would you explain how I might go about implementing the Image DataObjectManager class? Or at least point me to some explanatory documentation? - thanks in advance.
-
Re: Cannot Reference Banner Image more than Once

4 September 2010 at 2:39am
It’s part of the Data Object Manager extension: http://www.silverstripe.org/dataobjectmanager-module/
which has pretty good documentation.
You can also check out UncleCheese’s (who develops it) screencast: http://www.leftandmain.com/silverstripe-screencasts/2010/08/23/a-quick-look-imagegallery-module/
-
Re: Cannot Reference Banner Image more than Once

4 September 2010 at 2:42am
Thank you! I will evaluate this alternative and let you (and everyone in the forum) know how it turns out!
| 845 Views | ||
|
Page:
1
|
Go to Top |


