1

I use content types for image gallery and write own custom node for image gallery all images are show in custom node by following code but i don't know how to print the image title.

In this code i have given static title 'Circles and Cycles ' and i need dynamically title of every image.

<div id="node-<?php print $node->nid; ?>" class="node-gallery">
<ul class="product-grid">

    <?php
        $imgcount = count($node->field_gallery_image['und']);
        for ($i = 0; $i < $imgcount; $i++) {
        $image_uri = $node->field_gallery_image['und'][$i]['uri'];
            // url
            $masthead_raw = image_style_url('gallery-thumb', $image_uri);

    ?>
      <li>
        <div class="main-product-wrapper">
          <a href="<?php print file_create_url($node->field_gallery_image['und'][$i]['uri']); ?>" rel="group-<?php print $node->nid; ?>" class="product-link">
       <div class="product-item"> <img class="image<?php print ($i + 1);?>" src="<?php print $masthead_raw; ?>" /></div></a>
          <div class="product-title"><a href="#">Circles and Cycles</a></div>

      </li>
      <?php
        }?>
    </ul>

  </div>

The gallery page

1 Answer 1

0

Create a view of your content type, then in this view select the fields as your content and then select the title and the image. then every image will have its own title. you can also theme it in any way that you want.

you need to output this view in your node page, so simply in your template.php and in hook_preprocess_node function suggest a theme hook for this content type (for example page--node--gallery.tpl.php) and then in the page--node--gallery.tpl.php output the view using views_embed_view("view_name","display").

2
  • sir, i want to print the image title programmatically at node--gallery.tpl.php like image without making view.
    – ashok
    May 19, 2014 at 10:39
  • It is possible to create a view and embed it in the node page. But I'm surprising why you are insisting on doing this with out the views while views make it very easy !
    – M a m a D
    May 19, 2014 at 13:19

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.