Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

Help with displaying PHP in table


  • Please log in to reply
4 replies to this topic

#1 samlf3rd

samlf3rd

  • Members
  • 72 posts
  • OFFLINE
  •  
  • Local time:05:10 AM

Posted 10 August 2012 - 10:24 AM

I have a custom template installed on one of our sites, and the developer made everything look nice except extra images. The images display vertically instead of horizontally like I want. The more images we add the longer the page-it looks horrible.

Here is the code that renders the images (if there are any):

<div class="vmj_extraimage" style="width:96%; text-align: center;margin:8px auto;font-weight:bold;">
			<?php echo $this->vmListAdditionalImages( $product_id, $images ); ?>
		</div>

How can I make this data display in a table with 4 columns and as many rows as needed?

Thank you in advance!

BC AdBot (Login to Remove)

 


#2 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:03:10 AM

Posted 11 August 2012 - 07:55 AM

The code that does the actual listing is in a function called vmListAdditionalImages. We wpi;d need to see that bit of code. Or you can just bypass it and write your own code. You simply need a loop or two, depending on how you want to do it. With a single loop, the code flow would be something like this:

loop while count($images) > i
  display image[i]
  if i%4 == 0, start a new line

The actual code will only be slightly more complex. There are multiple examples available on google.

#3 samlf3rd

samlf3rd
  • Topic Starter

  • Members
  • 72 posts
  • OFFLINE
  •  
  • Local time:05:10 AM

Posted 16 August 2012 - 02:57 PM

The code that does the actual listing is in a function called vmListAdditionalImages. We wpi;d need to see that bit of code. Or you can just bypass it and write your own code. You simply need a loop or two, depending on how you want to do it. With a single loop, the code flow would be something like this:

loop while count($images) > i
  display image[i]
  if i%4 == 0, start a new line

The actual code will only be slightly more complex. There are multiple examples available on google.


Here is the code from my template for that function:
function vmlistAdditionalImages( $product_id, $images, $title='', $limit=1000 ) {
		global $sess;
		$html = '';
		$i = 0;
		foreach( $images as $image ) { 
			$thumbtag = ps_product::image_tag( $image->file_name, 'class="browseProductImage"', 1, 'product', $image->file_image_thumb_width, $image->file_image_thumb_height );
			$fulladdress = $sess->url( 'index2.php?page=shop.view_images&amp;image_id='.$image->file_id.'&amp;product_id='.$product_id.'&amp;pop=1' );
			
			if( $this->get_cfg('useLightBoxImages', 1 )) {
				$html .= vmCommonHTML::getLightboxImageLink( $image->file_url, $thumbtag, $title ? $title : $image->file_title, 'product'.$product_id );
			}
			else {
				$html .= vmPopupLink( $fulladdress, $thumbtag, 640, 550 );
			}
			$html .= ' ';
			if( ++$i > $limit ) break;
		}
		return $html;
	}

Thank you in advance for you help. I am lost on this.

#4 samlf3rd

samlf3rd
  • Topic Starter

  • Members
  • 72 posts
  • OFFLINE
  •  
  • Local time:05:10 AM

Posted 16 August 2012 - 04:00 PM

or perhaps it is this one sorry:
function vmMoreImagesLink( $images ) {
		global $mosConfig_live_site, $VM_LANG, $sess;
		/* Build the JavaScript Link */
		$url = $sess->url( "index2.php?page=shop.view_images&amp;flypage=".@$_REQUEST['flypage']."&amp;product_id=".@$_REQUEST['product_id']."&amp;category_id=".@$_REQUEST['category_id']."&amp;pop=1" );
		$text = $VM_LANG->_('PHPSHOP_MORE_IMAGES').'('.count($images).')';
		$image = vmCommonHTML::imageTag( VM_THEMEURL.'images/more_images.png', $text, '', '16', '16' );
		
		return vmPopupLink( $url, $image.'<br />'.$text, 640, 550, '_blank', '', 'screenX=100,screenY=100' );
	}



#5 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:03:10 AM

Posted 18 August 2012 - 07:49 AM

And that is calling yet another function, on another page perhaps. Look for a page called vmCommonHTML, and look for a page called getLightboxImageLink.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users