Hello all. I'm using image_gallery_2.3 with SS 2.4.1 and I'm trying to dynamically create h1 selectors specific to each album, and obviously these CSS selectors need to be without spaces (i.e. slugized). So I would love to be able to call $URLSegment and get the name of the Album, but it only returns the main Photo Gallery SS page, which makes sense:
http://localhost:8888/about/photo-albums/album/a-look-back/
returns photo-albums
So I've added this function to ImageGalleryPage.php:
public function SlugizedAlbumTitle()
{
$str = $this->CurrentAlbum()->AlbumName;
$str = strtolower(trim($str));
$str = preg_replace('/[^a-z0-9-]/', '-', $str);
$str = preg_replace('/-+/', "-", $str);
return rtrim($str, '-');
}
and it works just as I need, but obviously I'd much prefer to put a function in to my *own* code (e.g. /mysite/code/Page.php), but there I'm stumped. I've tried Director::URLParam('ID'), but with no magic.
Any tips would be greatly appreciated,
Patrick