• Hey Gang,

    Preface: I’m not a PHP expert by any means, but I’ve dicked around with WordPress for long enough to get several sites up and running with heavy customization just fine.

    That said, I seem to be having extraordinary difficulty with what should be a simple conditional statement: using a custom theme for the NGGallery Plugin, I’d like to display a link only IF the image in the gallery has a description ($image->description). Here is the loop I’ve got running:

    <ul id="slide-items">
      <?php foreach ($images as $image) : ?><?php if ( !$image->hidden ) : ?>
        <li class="image">
    		<div class="wrap">
    			<div class="frame">
    
    				<img title="<?php echo $image->alttext ?>" alt="<?php echo $image->alttext ?>" src="<?php echo $image->imageURL ?>" <?php echo $image->size ?> />
    
    				<div class="description">
    					<h2><?php echo $image->alttext ?></h2>
    					<p><?php echo $image->description ?></p>
    				</div>
    			</div>
    
    			<p class="piece-title"><?php echo $image->alttext ?></p>
    			<?php if (!empty($image->description)) { ?>
    			<p class="more-info-link"><a href="#" class="more-info">More Information</a></p>
    			<?php } ?>
    		</div><!-- .wrap -->
    	</li>
      <?php endif; ?><?php endforeach; ?>
      </ul>

    This shows the images and everything beautifully, except that the “more-info-link” appears whether or not a description for a particular image has been filled in via the plugin’s admin panel. I’ve also tried several combinations of conditionals to check whether the $image->description is null, an empty string, along with isset(), etc.

    The interesting thing to note is that if I can get the output to change, it changes the display of the link for all of the images, rather than just the ones that have no description.

    This seems like it should be a no-brainer, so what am I missing here?

  • The topic ‘NGGallery Conditional Statement Problems’ is closed to new replies.