Member
Member
sambody   2008-11-26, 13:00
#1
Hi. I'd like to find a way to add a css class (or id) to the body element, depending on the main parent album that I'm in. So that I can create special styles only for certain albums. For example: <body class="parent-album-id-7">. Does anyone know how to do this ?
Administrator
Administrator
acrylian   2008-11-26, 13:16
#2
This function gets the top level parent of an album:
http://www.zenphoto.org/documentation/functions/_functions.php.html#functiongetUrAlbum
Member
Member
sambody   2009-01-08, 19:50
#3
So how exactly should I use it ? I have tried these:
<body class="top_album_<?php getUrAlbum() ?>">
<body class="top_album_<?php getUrAlbum("mariages") ?>">
<body class="top_album_<?php getUrAlbum(mariages) ?>">
<body class="top_album_<?php getUrAlbum($album) ?>">
none of them work - I get top_album_(empty) . What should I replace "$album" with ?
Administrator
Administrator
acrylian   2009-01-08, 20:05
#4
If you want it to be printed you need use `<?php echo getUrAlbum($album) ?>`.
Member
Member
sambody   2009-01-08, 20:42
#5
I've tried `<?php echo getUrAlbum($album) ?>`, but I still get no result - it's just empty. You can see a gallery page here.

The image is the album "mariages", which is in the album "laeticia". I need to get that top album printed. Any ideas ?
Administrator
Administrator
acrylian   2009-01-08, 21:26
#6
You need to pass the album object of the current album to that function (sorry forgot to say but it's actually documentated):
`getUrAlbum($_zp_current_album);`
Member
Member
sambody   2009-01-08, 22:15
#7
still no success - worse, it actually makes everthing coming after `<body id="page_album" class="top_album_` totally disappear from the html source code (so page content is gone)... What am I doing wrong ?
Member
Member
sambody   2009-01-08, 23:03
#8
the zenphoto files (index.php, zp-core folder etc) are in the root folder - could this be the problem ? (or the fact that php safe mode is still on ?)
Member
Member
sbillard   2009-01-09, 02:28
#9
You should review the function definition/documentation for that function. It returns an album object, not a string. Try `$album = getUrAlbum($_zp_current_album); echo $album->name;`

Generally, it is a good idea to read the documentation on functions you intend to use. Don't expect the developers to remember details while reading posts.
Member
Member
sambody   2009-01-09, 20:35
#10
Thank you sbillard and acrylian. My body element now looks like this: `<body id="album_<?php $album = getUrAlbum($_zp_current_album); echo $album->name; ?>">` - it works.

Sorry for my ignorance. Thanks again.
  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.