selective lightbox

Status
Not open for further replies.

Hefemeister

Lord Techie,
Messages
9,093
Location
Sweden
Ok total noob so go easy on me.

I have a template that will pull all images and put them into thumbs so they can be viewed in lightbox.

Code:
<?php
/*
Template Name: mosaic
*/
?>

<?php get_header(); ?>

<div class="thumbwall_container">

		<?php $temp_query = clone $wp_query; ?>
		<?php query_posts('showposts=1734'); ?>
			<?php while (have_posts()) : the_post();?> 
			<?php if (in_category('blog')) continue; 
		if ($images = get_children(array(
			'post_parent' => $post->ID,
			'post_status' => 'inherit',
			'post_type' => 'attachment',
			'post_mime_type' => 'image',
			'order' => 'ASC',
			'orderby' => 'menu_order')))  
	  
		foreach($images as $image) {  
			$viso_image = $image->guid; 
			$viso_thumb = wp_get_attachment_thumb_url( $image->ID, $size); 
			if (current_user_can('level_2')) {} else { if (in_category('private')) 
			{$viso_thumb = site_url('/wp-content/themes/viso/images/private_extrasmall.png');
			$viso_image = site_url('/wp-content/themes/viso/images/private_info.png');}}?>				
				
	
			
		<div class="thumbwall_box" style="background:url(<?php echo $viso_thumb; ?>) no-repeat center center; ">
			<div class="thumbwall_box_link"><a href="<?php echo $viso_image; ?>" rel="lightbox[mset]" title="<?php the_title(); ?>"></a>
			</div>
		</div>
		
<?php } else { ?>

		<div class="thumbwall_box" style="background:url(<?php bloginfo ('template_directory'); ?>/images/noimage.png) no-repeat center center; ">
			<div class="thumbwall_box_link"><a href="<?php bloginfo ('template_directory'); ?>/images/noimage_big.png" rel="lightbox[mset]" title="<?php the_title(); ?>"></a>
			</div>
		</div>

			
<?php }  ?>			
			
			<?php endwhile; ?>
	 
		   <?php $wp_query = clone $temp_query; ?></div>
	<div class="clear"></div>



</div>


<?php get_footer(); ?>

I am trying to edit it such that only pictures assigned to a specific category will be displayed.

Example:
I have a gallery page with all images using the above template. I want a sub page that will only display pictures in the kids category. I thought this would do it but to no avail.

Code:
<?php
/*
Template Name: kids
*/
?>

<?php get_header(); ?>

<div class="thumbwall_container">

			<?php while (have_posts()) : the_post();?> 
			<?php if (in_category('blog')) continue; 
		if ($images = get_children(array(
			'post_parent' => $post->ID,
			'post_status' => 'inherit',
			'post_type' => 'attachment',
			'post_mime_type' => 'image',
			'order' => 'ASC',
			'orderby' => 'menu_order')))  
	  
		foreach($images as $image) {  
			$viso_image = $image->guid; 
			$viso_thumb = wp_get_attachment_thumb_url( $image->ID, $size); 
			if (current_user_can('level_2')) {} else { if (in_category('private')) 
			{$viso_thumb = site_url('/wp-content/themes/viso/images/private_extrasmall.png');
			$viso_image = site_url('/wp-content/themes/viso/images/private_info.png');}}?>				
				
	
			
		<div class="thumbwall_box" style="background:url(<?php echo $viso_thumb; ?>) no-repeat center center; ">
			<div class="thumbwall_box_link"><a href="<?php echo $viso_image; ?>" rel="lightbox[mset]" title="<?php the_title(); ?>"></a>
			</div>
		</div>
		
<?php } else { ?>

		<div class="thumbwall_box" style="background:url(<?php bloginfo ('template_directory'); ?>/images/noimage.png) no-repeat center center; ">
			<div class="thumbwall_box_link"><a href="<?php bloginfo ('template_directory'); ?>/images/noimage_big.png" rel="lightbox[mset]" title="<?php the_title(); ?>"></a>
			</div>
		</div>

			
<?php }  ?>			
			
			<?php endwhile; ?>
	 
		</div>
	<div class="clear"></div>



</div>


<?php get_footer(); ?>

Thanks everyone for their input.
 
When I'm writing PHP I don't embed the it into HTML, instead I use the whole file for one PHP script which reduces complexity a lot and if there are blocks of HTML that need to be output, I wrap the it in a PHP variable with EOT tags. The problem here is that you have multiple scripts which means that everything else is out of scope.
For me running either of these files returns "undefined function" for get_header() on line 7. get_header() is probably defined elsewhere but you need to tell your script where that is (with include or include_once).
Unfortunately, these files are both quite wrong, but in my eyes the first thing to do is to make it one php script and put whatever includes you need for these functions.
 
I always make a showPage class in a separate file to start off with. Then when you need to add a new page it's extremely easy.

Unfortunately Tom's right. It's very hard to pinpoint one thing in that code without it being rewritten the other way around. Use .php files and put your HTML in them.

Just contact me on MSN if you have questions. You have my number :p
 
Status
Not open for further replies.
Back
Top Bottom