Problem with displaying the album name.
-
The template ‘album-compact.php’ contains :
// $album : Contain information about the album<?php var_dump($album);?> shows ‘NULL’
Why?
Is this a bug?
How to display the album name?
-
@piotr Pieczykolan – Would you mind pointing us to the page on your site that is displaying the Compact album without gallery titles?
Thanks! (Becky)
gallery titles – yes
album title – noPiotr
I would like to display the title of the album.
Gallery titles display correctly.Piotr
http://wp.6scian.eu/wnetrza-prywatne/
1. I made a copy of the template:
wordpress/wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/ngglegacy/view/album-compact.php
wordpress\wp-content\themes\temat1\nggallery\album-compact-6scian.php2. I added to the template php code :
<?php echo '<!-- album '; var_dump($album); echo ' -->'; ?>3. Page content:
[ngg_images album_ids=1 display_type=photocrati-nextgen_basic_compact_album]
[ngg_images album_ids=2 display_type=photocrati-nextgen_basic_compact_album]
[ngg_images album_ids=3 display_type=photocrati-nextgen_basic_compact_album]4. Effect
<!-- album NULL -->I would like to display ‘Album name’ and ‘Album description’
WordPress: 3.7.1
NextGEN Gallery 2.0.33Piotr
I also need to get the title of the album. Piotr, did you fix this?
Does the $album array even exist?
WordPress: 3.8.1
NextGEN Gallery 2.0.58it is ok
Piotr
How do you get the album name then? I’m using the latest versions of WordPress and NextGen.
\wp-content\themes\my_theme\nggallery\album-compact.php :
<?php echo $album->name; echo '<br />'; echo $album->albumdesc; echo '<br />'; ?>Thanks for the quick reply, but this just comes up blank for me. I’ve created a new template page from the exact same php page you’ve used – “album-compact.php”.
Is assigned the template to the gallery?
edit page / edit gallery:
Customize the display settings / Template / Parent Theme: album-compact.phpYep, I’ve got it set to the Template, and I know the template is being used because I’ve customized it, so I can any other changes I make.
But using $album to select any variables just doesn’t work at all.
my test page (var_dump):
<!-- ======= object(stdClass)#2454 (10) { ["id"]=> int(1) ["name"]=> string(4) "alb1" ["slug"]=> string(4) "alb1" ["previewpic"]=> int(2) ["albumdesc"]=> string(22) "Opis albumu pierwszego" ["sortorder"]=> array(1) { [0]=> string(1) "2" } ["pageid"]=> int(0) ["extras_post_id"]=> int(73) ["id_field"]=> string(2) "id" ["exclude"]=> int(0) } -->@pixelkicks – It looks like @piotr Pieczykolan covered everything in his responses (thanks!), I would suggest doing a
var_dump( $album );as a test in your template as well.– Cais.
<?php var_dump( $album ); ?> shows…
NULL
This happens wherever I place it in the template.
Here is the full template code I currently have (with some terrible hacky code because I can’t pull out the album name):
<?php /** Template Page for the album overview Follow variables are useable : $album : Contain information about the album $galleries : Contain all galleries inside this album $pagination : Contain the pagination content You can check the content when you insert the tag <?php var_dump($variable) ?> If you would like to show the timestamp of the image ,you can use <?php echo $exif['created_timestamp'] ?> **/ ?> <?php if (!defined ('ABSPATH')) die ('No direct access allowed'); ?><?php if (!empty ($galleries)) : ?> <?php var_dump( $album ); ?> <div class="ngg-albumoverview"> <!-- List of galleries --> <?php $gallcount = 0; ?> <?php foreach ($galleries as $gallery) : ?> <?php if (strpos($gallery->pagelink,"grooming")) { $gallcount += 1; if ($gallcount < 2) { echo "<p>The Grooming Salon</p>"; } } else { $gallcount += 1; if ($gallcount < 2) { echo "<p>Before & After...</p>"; } } echo $gallery->counter; ?> <div class="ngg-album-compact"> <div class="ngg-album-compactbox"> <div class="ngg-album-link"> <a class="Link" href="<?php echo nextgen_esc_url($gallery->pagelink) ?>"> <img class="Thumb" alt="<?php echo esc_attr($gallery->title) ?>" src="<?php echo nextgen_esc_url($gallery->previewurl) ?>"/> </a> </div> </div> <?php if (!empty($image_gen_params)) { $max_width = 'style="max-width: ' . ($image_gen_params['width'] + 20) . 'px"'; } else { $max_width = ''; } ?> <h4> <a class="ngg-album-desc" title="<?php echo esc_attr($gallery->title) ?>" href="<?php echo nextgen_esc_url($gallery->pagelink) ?>" <?php echo $max_width; ?>> <?php echo $gallery->title ?> </a> </h4> <?php if (@$gallery->counter > 0) : ?> <p><strong><?php echo $gallery->counter ?></strong> <?php _e('Photos', 'nggallery') ?></p> <?php endif; ?> </div> <?php endforeach; ?> <!-- Pagination --> <br class="ngg-clear"/> <?php echo $pagination ?> </div> <?php endif; ?>@pixelkicks – Your template (from the above) works just fine (in a local install test) to show the
var_dumpdata … are you having any specific issues with the album you are using as part of your tests?– Cais.
The topic ‘Problem with displaying the album name.’ is closed to new replies.