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.

All other Modules /

Discuss all other Modules here.

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

Use a Gallery in another page


Reply


564 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.