summaryrefslogtreecommitdiff
path: root/src/generators.c
diff options
context:
space:
mode:
authorTomas Bzatek <tbzatek@users.sourceforge.net>2015-02-01 17:43:20 +0100
committerTomas Bzatek <tbzatek@users.sourceforge.net>2015-02-01 17:43:20 +0100
commit44640c813bc030f92235ef16fbe4680f5e811b13 (patch)
tree6ca52b67a4071841628ef2a3e88061e4c90e3d9d /src/generators.c
parent693456179b2047269a5ba1942b1d0fc4ba10dbc7 (diff)
downloadcataract-44640c813bc030f92235ef16fbe4680f5e811b13.tar.xz
generators: Expose ITEM_INDEX value for non-picture items
The returned number corresponds with the next picture item ID, for templates to present related information (i.e. section beginning) for the particular picture.
Diffstat (limited to 'src/generators.c')
-rw-r--r--src/generators.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/generators.c b/src/generators.c
index 3bd00a3..c1eaf5a 100644
--- a/src/generators.c
+++ b/src/generators.c
@@ -117,7 +117,8 @@ get_display_item_index (TAlbum *items, TIndexItem *item)
if (tmp_item->type == INDEX_ITEM_TYPE_PICTURE && (! tmp_item->hidden))
real_item_index++;
if (tmp_item == item)
- return real_item_index;
+ /* non-picture items shall be index-bound to the next picture item */
+ return real_item_index + ((tmp_item->type != INDEX_ITEM_TYPE_PICTURE) ? 1 : 0);
}
return 0;
}
@@ -1154,11 +1155,13 @@ write_html_page (TGallerySetup *setup,
case INDEX_ITEM_TYPE_SEPARATOR:
s1 = block_parser_get_data (block_parser, "LIST_SEPARATOR");
replace_table_add_key (local_replace_table, "LIST_SEPARATOR_TITLE", iter_item->title);
+ replace_table_add_key_int (local_replace_table, "ITEM_INDEX", get_display_item_index (items, iter_item));
break;
case INDEX_ITEM_TYPE_INTERSPACE:
s1 = block_parser_get_data (block_parser, "LIST_INTERSPACE");
replace_table_add_key (local_replace_table, "LIST_INTERSPACE_TITLE", iter_item->title);
+ replace_table_add_key_int (local_replace_table, "ITEM_INDEX", get_display_item_index (items, iter_item));
break;
}