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.

All other Modules /

Discuss all other Modules here.

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

Use a Gallery in another page


Go to End


1251 Views

Avatar
sca123

Community Member, 61 Posts

8 November 2010 at 7:21am

I have the following setup:

(a) class Yacht extends dataobject and has ImageGalleryPageID which stores the pageID of a linked Gallery Page.

(b) Template LocationPage uses <% control Yacht %>

What I need to do is to show the gallery(a) into the control of the template (b)

I've tried using the following in class Yacht:

function Gallery() {
$page_link = $this->ImageGalleryPageID;
if (!$page_link) return "";
try
{
$class = "SiteTree";
$where = "'SiteTree.ID'= '$page_link'";
$obj = DataObject :: get($class, $where);
} catch (Exception $e) {
if (!Director :: isDev())
Debug :: Show($e);
}
return $obj;
}

The using the following in the page template:

<% control Yachts %>
<% control Gallery %>
$GalleryLayout
<% end_control %>
<% end_control %>

But this doesn't work. Any help given would be appreciated.