/** * Return a URI to an exhibit. * * @param Exhibit $exhibit If null, it uses the current exhibit. * @param ExhibitPage $exhibitPage A specific page to link to * @return string */ function exhibit_builder_exhibit_uri($exhibit = null, $exhibitPage = null) { if (!$exhibit) { $exhibit = get_current_record('exhibit'); } $exhibitSlug = $exhibit instanceof Exhibit ? $exhibit->slug : $exhibit; //If there is no page slug available, we want to build a URL for the summary page if (!$exhibitPage) { $uri = public_url(array('slug' => $exhibitSlug), 'exhibitSimple'); } else { $pagesTrail = $exhibitPage->getAncestors(); $pagesTrail[] = $exhibitPage; $options = array(); $options['slug'] = $exhibitSlug; foreach ($pagesTrail as $index => $page) { $adjustedIndex = $index + 1; $options["page_slug_{$adjustedIndex}"] = $page->slug; } $uri = public_url($options, 'exhibitShow', array(), true); } return $uri; }