Pages: 1
Hi,
in my photos I have stored information about the author's website in the IPTC field "Copyright Info URL".
Now I want to import this information into Piwigo and show the website url in the category view.
I have set up an example page here: http://piwigo.i-flora.com/index.php?/category/1
I finally found out how to import the IPTC data. But how can I show this information in the category view?
It would be great to have some variable like {$thumbnail.URL} in my template thumbnails.tpl
Regards
Ralf
Piwigo version: 2.10.2
PHP version: 7.3.10
Piwigo URL: http://piwigo.i-flora.com
Offline
Okay, I found out that the variables for the template thumbnails are defined in include/category.default.inc
By adding 'AUTHOR'=> $row['author'] to the array $tpl_var the copyright link (which I stored in the field author) is assigned to the smarty variable {$thumbnail.AUTHOR}, which I can use in thumbnail.tpl.
$tpl_var = array_merge( $row, array(
'TN_ALT' => htmlspecialchars(strip_tags($name)),
'TN_TITLE' => get_thumbnail_title($row, $name, $desc),
'URL' => $url,
'AUTHOR'=> $row['author'],
'DESCRIPTION' => $desc,
'src_image' => new SrcImage($row),
) );
I know, I shouldn't alter the Piwigo source code. How can I add this definition in my own plugin?
Thanks for any hint.
Last edited by egretta (2020-10-28 11:52:39)
Offline
Offline
Thanks for your hint.
Meanwhile I found out, there is no need to define a new $author variable as the variable {$thumbnail.author} already exists in the template thumbnails.php
Anyway, defining a new variable - i.e. {$thumbnail.CUSTOM} - for the template thumbnails.php can be done like this.
1. LocalFiles Editor > Personal Plugin
2. Insert
<?php
/*
Plugin Name: Personal Plugin
Version: 1.0
Description: Personal Plugin
Plugin URI: http://piwigo.org
Author:
Author URI:
*/
add_event_handler('loc_end_index_thumbnails', 'add_thumbnail_variable');
function add_thumbnail_variable($tpl_thumbnails_var)
{
foreach (array_keys($tpl_thumbnails_var) as $id)
{
$tpl_thumbnails_var[$id]['CUSTOM'] = 'My custom variable';
}
return $tpl_thumbnails_var;
}
3. Activate Personal Plugin
Last edited by egretta (2020-11-01 16:32:06)
Offline
nice work
Offline
Pages: 1