7913 Posts in 1355 Topics by 930 members
DataObjectManager Module
SilverStripe Forums » DataObjectManager Module » Gallery. Get the first Image.
Discuss the DataObjectManager module, and the related ImageGallery module.
Moderators: martimiz, UncleCheese, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 553 Views |
-
Gallery. Get the first Image.

18 May 2010 at 9:06am Last edited: 18 May 2010 9:10am
Hi I Use DataObjectManager Modul
And I create a realy simple Gallery, and everything works perfect, but now i want to make some kind of Holder lets say a KatalogImageHolder.php where the children are KatalogImagePage, where I want to show only the first Image of the KatalogImagePage. And I have no Idea how can I do that stuff
(I Know this is not so really appended from DataObjectManager Modul)
Please Help me to get it work
KatalogImageHolder.php looks like this
class KatalogImageHolder extends Page {
static $db = array(
);static $has_one = array(
);
static $allowed_children = array('KatalogImagePage');
}
….and KatalogImagePage.php like this
class KatalogImagePage extends Page
{
static $has_many = array (
'KatalogImages' => 'KatalogImage'
);
// Here go, I don't know how to make it run,
public function getFirstPhoto(){
return $this->KatalogImages[0]; //that doesn't work
}
...@UncleCheese. My Post has been duplicated, please delete one of them
-
Re: Gallery. Get the first Image.

18 May 2010 at 9:25am
In the template:
$KatalogImages.First
In the controller:
$this->KatalogImages()->First();
-
Re: Gallery. Get the first Image.

18 May 2010 at 9:38pm
Oh men, @UncleCheese
I knowed, I've read about this, but many , many months ago ;)
It is working now, thanks for your help
| 553 Views | ||
|
Page:
1
|
Go to Top |

