0

I will create the portfolio gallery page using custom content types with thumbnail and bigimage image fields. then i am using the following code for rendering content types

<?php 
$content_type = 'websiteportfolio';
$query = new EntityFieldQuery();

$entities = $query->entityCondition('entity_type', 'node')
->entityCondition('bundle', $content_type)
->propertyCondition('status', 1)
->pager(9)
->execute();
$nodes = entity_load('node', array_keys($entities['node']));?>


<?php
  $i = 1;
  foreach($nodes as $val=>$key1)

  {

 ?>


 <div class="thumbnail-box">
<a href=<?='sites/default/files/'. $key1->field_bigimage['und']['0']['filename']; ?> rel="lightbox[portfolio]"  title="<?= 'Portfolio'.$i ?>"><img src=<?='sites/default/files/websiteportfolio/'. $key1->field_images['und']['0']['filename']; ?> alt="<?= 'Portfolio'.$i ?>" /></a>

</div>

 <?php 
$i++;
}


 ?>

finally i got the 9 thumbnail images in my page and also light box functionality working well.My issue Only show first 9 images I need pagination for showing the remaining images how can fix this issue..

1 Answer 1

1

First things first, that code shouldn't be in the template file; it should be in a preprocess function. The reasons for this have been documented at great length both on this site and the internet in general so I won't go into them here.

You might also find the l() function interesting, as well as theme_image()...API replacements for the custom HTML you're building up.

Other than that, the only thing you're missing is the code to actually render the pager; that would entail adding this to your preprocess function, after the query has been run:

$vars['pager'] = theme('pager');

And in the template file simply outputting it wherever you'd like it:

<?php echo $pager; ?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.