IPTC Caption to page title

pumaka

Joined: 2007-05-14
Posts: 40
Posted: Fri, 2008-01-04 02:58

Hello,
I want to customize the title of my album.tpl pages (photo pages). I'd like to set it to IPTC: Caption. (Example: photo has IPTC Caption "blue bird", I'd like "blue bird" to be the title of the page. )

Anyone know how to do it?

Thanks in advance!

Login or register to post comments
floridave
floridave's picture

Joined: 2003-12-22
Posts: 16315
Posted: Fri, 2008-01-04 03:14

First you will want to edit photo.tpl for the photo pages. Then:
http://gallery.menalto.com/node/70717#comment-254616

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

Login or register to post comments
pumaka

Joined: 2007-05-14
Posts: 40
Posted: Fri, 2008-01-04 04:05

Hi Dave,
this is not what I'm looking for or perhaps I misunderstood?

I want the <title> of the page (<title>page title</title) to be what my IPTC: Caption is for any given image. And in my first post I incorrectly said "album.tpl" while I meant "theme.tpl". I want to edit this file because this is the only place where I found <title> and as I understand, it sets the title for the entire site.

I figured out how to display Album name in page title, but would also like to include the IPTC Caption.

Thank you.

Login or register to post comments
floridave
floridave's picture

Joined: 2003-12-22
Posts: 16315
Posted: Fri, 2008-01-04 06:22

When viewing a album where do you want to get the IPTC: Caption data?

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

Login or register to post comments
pumaka

Joined: 2007-05-14
Posts: 40
Posted: Fri, 2008-01-04 15:55

When a thumbnail is clicked (so you're at the photo page), I want IPTC Caption to be the title of the page.

Title of the page - I mean title that's in HTML between tags <title> and </title>. For example the title of this forum page in the browser (at the top left) is "IPTC Caption to title | Gallery". This is where I want IPTC Caption to show up.

Thank you.

Login or register to post comments
floridave
floridave's picture

Joined: 2003-12-22
Posts: 16315
Posted: Fri, 2008-01-04 17:40

How farmilar are you with smarty tags and {if} statements? The code from the thread I mentioned is the vast majority of the code required to extract a single field from the EXIF data of a photo.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

Login or register to post comments
pumaka

Joined: 2007-05-14
Posts: 40
Posted: Fri, 2008-01-04 18:02

I'm not very familiar with them. Pretty much everything I've been able to achieve manipulating the tags was by lengthy trial and error. I tried putting different parts of your code into my <title> but it's not working.

Here's my title right now:
<title>
{$theme.item.title|markup:strip|default:$theme.item.pathComponent}
{$theme.item.description|markup}
{$theme.item.IPTC.Caption} </title>

This displays the Album name AND Photo Description. However, not all my pictures have descriptions, some of them only have IPTC: Caption. Can I somehow carry over the IPTC: Caption to be also Photo description automatically?

Thank you for your patience! I'm just stumbling in the dark here.

Login or register to post comments
floridave
floridave's picture

Joined: 2003-12-22
Posts: 16315
Posted: Sat, 2008-01-05 03:42

So you want to check to see if {$theme.item.IPTC.Caption} is not empty and use {$theme.item.description|markup} if it is empty?

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

Login or register to post comments
floridave
floridave's picture

Joined: 2003-12-22
Posts: 16315
Posted: Sat, 2008-01-05 03:49

Just to confirm, You managed to get {$theme.item.IPTC.Caption} to display if it has the data in the photos EXIF data?

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

Login or register to post comments
pumaka

Joined: 2007-05-14
Posts: 40
Posted: Thu, 2008-02-07 08:02

{$theme.item.IPTC.Caption} shows what I enter manually in the "Description" field (under Edit Photo, where it says "This is the long description of the item.")

Login or register to post comments
floridave
floridave's picture

Joined: 2003-12-22
Posts: 16315
Posted: Sat, 2008-01-05 20:55
Quote:
{$theme.item.IPTC.Caption} shows what I enter manually in the "Description" field (under Edit Photo, where it says "This is the long description of the item.")

Can you show me in your template code where you are using:
{$theme.item.IPTC.Caption}
?

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

Login or register to post comments
pumaka

Joined: 2007-05-14
Posts: 40
Posted: Sat, 2008-01-05 23:29

Hi Dave,
please see attached file.

AttachmentSize
theme.tpl4.52 KB
Login or register to post comments
pumaka

Joined: 2007-05-14
Posts: 40
Posted: Sat, 2008-01-05 23:35

For some reason I can't view my attachment above (no permissions). In case you're unable to view it too, here's the code (relevant part):

{*
* $Revision: 15342 $
*}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="{g->language}">
<head>
{* Let Gallery print out anything it wants to put into the <head> element *}
{g->head}
{* If Gallery doesn't provide a header, we use the album/photo title (or filename) *}
{if empty($head.title)}

{*Here's the title*}

<title>AR Stock - Rights-Managed Stock Photography - {$theme.item.title|markup:strip|default:$theme.item.pathComponent} {$theme.item.description|markup}
{$theme.item.IPTC.Caption} </title>

{*end title*}

{/if}

{* Include this theme's style sheet *}
<link rel="stylesheet" type="text/css" href="{g->theme url="theme.css"}"/>
</head>
<body class="gallery">

Login or register to post comments
floridave
floridave's picture

Joined: 2003-12-22
Posts: 16315
Posted: Sun, 2008-01-06 00:44

{$theme.item.IPTC.Caption} does nothing. Where did you get that from?

Did you add some code from that post or are you lost now.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

Login or register to post comments
pumaka

Joined: 2007-05-14
Posts: 40
Posted: Sun, 2008-01-06 01:21

I just deleted that part and you're correct, it didn't change anything at all (manually entered description still shows up in page titles and "IPTC: Caption" does not).

To answer your question, I got {$theme.item.IPTC.Caption} from some module code. I was randomly copying/pasting stuff hoping something would show up as I wanted it.

I AM pretty confused at this point. If there is no manually entered description, can IPTC: Caption automatically take its place?

Do you teach kindergarten by any chance? You are very patient. Thank you :)

Login or register to post comments
floridave
floridave's picture

Joined: 2003-12-22
Posts: 16315
Posted: Sun, 2008-01-06 03:27

Not tested but I think it should work. Most of the code from the other post.
Edit theme.tpl

    {* If Gallery doesn't provide a header, we use the album/photo title (or filename) *}
    {if empty($head.title)}
      <title>{$theme.item.title|markup:strip|default:$theme.item.pathComponent}</title>
    {/if}
    {* If Gallery doesn't provide a header, we use the album/photo title (or filename) *}
    {* If a photo page the extract the IPTC: Caption for the title *}
    {if $theme.pageType == 'photo'}
        {if empty($item)} {assign var=item value=$theme.item} {/if}
        {* Load up the EXIF data *}
        {g->callback type="exif.LoadExifInfo" itemId=$item.id}
        {if !empty($block.exif.LoadExifInfo.exifData)}
             {assign var="exif" value=$block.exif.LoadExifInfo}
             {if !empty($exif.exifData)}
             {section name=outer loop=$exif.exifData step=2}
                 {section name=inner loop=$exif.exifData start=$smarty.section.outer.index max=2}
                 {* If have IPTC: Caption use it as the title ELSE show the item title *}
                 {if ($exif.exifData[inner].title == "IPTC: Caption")}
                     <title>{$exif.exifData[inner].value}</title>
                {else}
                     <title>{$theme.item.title|markup:strip|default:$theme.item.pathComponent}</title>
                 {/if}
                 {/section}
             {/section}
             {/if}
        {/if}
    {else}
    {if empty($head.title)}
      <title>{$theme.item.title|markup:strip|default:$theme.item.pathComponent}</title>
    {/if}
    {/if}

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

Login or register to post comments
pumaka

Joined: 2007-05-14
Posts: 40
Posted: Sun, 2008-01-06 04:36

It works! Never would've figured it out on my own.

Thank you very very much :)

Login or register to post comments
floridave
floridave's picture

Joined: 2003-12-22
Posts: 16315
Posted: Sun, 2008-01-06 06:48

Dave

_____________________________________________
Blog & G2 || floridave - Gallery Team

Login or register to post comments