Hi,

I want to display the title of an Image just below it. I've also created a custom text-field called "Pris" which I also want to display below the Image.

How do I do that?

Thanks.

Comments

dbeall’s picture

Hi cholden, You can do what you need by using the node-image-default.tpl.php file from the node_gallery/themes folder.

Rename it to node-node_gallery_image.tpl.php and place it inside your theme's folder with the other tpl.php files
Then customize that file to suit your needs..
such as move this part

<h2 class="title">
      <a href="<?php print $node_url; ?>"><?php print $title; ?></a>
    </h2>

down below the content div to look like this

<div class="content">
    <?php print $content; ?>
  </div>
<h2 class="title">
      <a href="<?php print $node_url; ?>"><?php print $title; ?></a>
    </h2>

If you don't want it to have a link, just use this part

<h2 class="title">
<?php print $title; ?>
</h2>

There is a quick bit in the handbook about this in 'style,views and theming'
http://drupal.org/node/544748#tpl

I did a quick test of a custom field added to the 'galley Image' content type and it displays below the image without doing any customizations.. You do have to edit the gallery relationship and check mark your new field for display.
http://drupal.org/node/544642#configr ,Configuration for Each Gallery Relationship

The handbook does need a few updates as some items are working better now with alpha11.
I will have a closer look at things in the handbook during the next 2 weeks and do some updates.

I am like everyone else, I learn more by helping and this helps the handbook get better to.
If you need some more help with this, please post it here and I will help you get this done..

cholden’s picture

Hi,

Thanks for your reply.

I've tried to follow your instructions, but can't get it to work. It's like the node-node_gallery_image.tpl.php file is ignored (and i have tried to clear the cache).

I've edited the relationship and enabled the new field I created. When i upload new images or edit existing ones the new field appears correctly. But when i view the gallery it doesn't display that filed.
http://grab.by/1hTx

I got the title to display just by removing a "display: none" in css.
http://grab.by/1hTy

Thanks.

dbeall’s picture

I tested the node-node_gallery_image.tpl.php with garland and goldfish themes, on a local wamp.
So the file was in root/themes/garland/[...tpl/php]. and the goldfish in the site/all/themes/goldfish/
If you have content permissions, the pris field has to be open to view(content type field setting) that is default(i believe).

arturus-1’s picture

For display the title gallery on page images of gallery i have added a code in the file node-image-default.tpl.php

   $gallery = db_fetch_object(db_query("SELECT n.title, n.nid  FROM {node} n INNER JOIN {node_galleries} ng ON n.nid = ng.gid
   WHERE ng.nid =".$node->nid));

    <h3 class="gallery">(<a href=node/<?=$gallery->nid?>>
	<?php print $gallery->title; ?>
	</a>)
    </h3>

Example here
http://club.shintoptrophy.ru/node/2389

dbeall’s picture

well, that is the hard way to do it. But the problem is that when you upgrade the node_gallery module, you will have to edit the file again.
node-image-default.tpl.php file should be copied to the theme folder and renamed to node-node_gallery_image.tpl.php

cholden’s picture

There are no changes at all when editing the node-image-default.tpl.php in the modules/node_gallery folder or when I'm duplicating and renaming it to theme-name/node-node_gallery_image.tpl.php

When I view the detailed-view of an image the custom "pris" field displays fine:
http://grab.by/1jPo

But it still doesn't in the image list:
http://grab.by/1jPp

Another problem is that I want the image to pop up in lightbox. It works perfect when clicking the thumbnail, but the title links to the node of the image like this screenshot also shows:
http://grab.by/1jPo

And I dont get what you mean by this:

If you have content permissions, the pris field has to be open to view(content type field setting) that is default(i believe).

Thanks.

dbeall’s picture

@cholden, the file needs to be copied to your theme folder.. They are kept in the node_gallery/theme folder for use when you need them. There are 6 available tpl files to use.
if you use a contributed theme, it would be in
sites/all/themes/'theme name'/node-node_gallery_image.tpl.php
if you use a core theme it would be in
themes/'theme name'/node-node_gallery_image.tpl.php

In the content type, there is 'manage fields' and 'display fields' settings, but it is on by default.
You can also set the title 'pris' to display 'inline' with the 'display fields' settings in the content type.
( administer > Content type > Gallery Image > Display fields )
+Also if you use CCK, it has a content permissions module, with field permissions.
( administer > User management > Permissions ) in CCK

The issue with lightbox not working with the title on-click.. not sure how to code that, but an easy work around is to remove the link action from the title..
In this part...

<h2 class="title">
      <a href="<?php print $node_url; ?>"><?php print $title; ?></a>
    </h2>

Change it to this..

<h2 class="title">
      <?php print $title; ?>
    </h2>

That way the title will show, but it has no link, which means they have to click the thumbnail which will open lightbox

To get the 'pris' field to show in thumbnail page..It would be in the gallery-image-thumbnail.tpl.php by adding it to your theme folder, then add the field to it. I am sure it's something like..
<div class="field-label"><?php print $title; ?></div>
But I don't know what to put in place of $title.. it might be more like..
<div class="field-label"><?php print $field_pris['#value']; ?></div>
I am not a cck expert, but the answer is someplace there.. I have to do a little more looking at that part. I have this in my local test install and I am looking for the answer..

dbeall’s picture

@cholden, I probably won't be able to do much this week as I am heading out today to my moms for xmass. her internet connection is crappy. will be back next week for sure.

dddave’s picture

Mmh, this could definitely need some documentation or better yet an easy UI.....

justintime’s picture

Status: Active » Fixed

Sounds like the original issue was resolved.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.