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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

Moderators: martimiz, UncleCheese, Sean, Ed, biapar, Willr, Ingo, swaiba

[SOLVED] [Image Gallery] Get the first album into the ImageGalleryPage


Go to End


5 Posts   2037 Views

Avatar
Raphael--

Community Member, 14 Posts

18 August 2009 at 2:26am

Edited: 18/08/2009 4:46am

Hi everybody,

I'd like to customize a bit the ImageGallery Page but I can't figure it out...

The default behavior:
When you arrive on an ImageGallery Page, it displays eather an albums list (if several albums) or directly the album if the Gallery include just one album.

The behavior that I'm trying to get:
When there is several albums, I would like to display the first album of the Galery directly.

See in action:
Here is a ImageGallery Page with two albums : http://silver.francesca-avossa.com/stand-2/
You need to click on "M&O 2008" or "M&E 2009" to display an album. Instead of doing that, I would like to be directly in the first album of the Galery.

Any ideas of how I can do that ?

Many thanks in advance.

Avatar
UncleCheese

Forum Moderator, 4102 Posts

18 August 2009 at 3:23am

Create a new class, MyImageGalleryPage extends ImageGalleryPage

MyImageGalleryPage_Controller extends ImageGalleryPage_Controller
{
function index() {
Director::redirect($this->Albums()->First()->Link());
}
}

Avatar
Raphael--

Community Member, 14 Posts

18 August 2009 at 3:54am

Edited: 18/08/2009 3:55am

Thank you UncleCheese, it works perfectly ! (cf http://silver.francesca-avossa.com/new-myimagegallerypage/ )

Just a quick question:
If I go into the Behavior tab of my ImageGalleryPages, I select my new type of page "MyImageGalleryPage" and I do a db/build?flush=1, the redirection doesn't work. It only works when I create a fresh new MyImageGallery Page. It means I will need to re-create all the ImageGalleryPage with this new type of page.

Do you know how I can avoid that ?

Thanks again.

Avatar
UncleCheese

Forum Moderator, 4102 Posts

18 August 2009 at 4:36am

Hmm.. That doesn't make any sense to me. Something isn't right.

FYI, you should be using /dev/build, not db/build?flush=1.

Avatar
Raphael--

Community Member, 14 Posts

18 August 2009 at 4:45am

Ok, nevermind. I'll figure it out.

Thanks again for your time.