to URL string variable
global $template;
//picture nav buttons
$links = array('first','previous','next','last');
$tags = array('U_IMG');
foreach ($links as $link) {
$temp = $template->get_template_vars($link);
foreach ($tags as $tag) {
if (isset($temp[$tag])) {
$temp[$tag] .= '#'.PANCHOR_NAME;
$template->assign($link, $temp);
}
}
}
//slideshow nav buttons
$links = array('slideshow');
$tags = array('U_START_PLAY', 'U_STOP_PLAY', 'U_START_REPEAT', 'U_STOP_REPEAT', 'U_DEC_PERIOD', 'U_INC_PERIOD');
foreach ($links as $link) {
$temp = $template->get_template_vars($link);
foreach ($tags as $tag) {
if (isset($temp[$tag])) {
$temp[$tag] .= '#'.PANCHOR_NAME;
$template->assign($link, $temp);
}
}
}
//start slideshow nav button
$temp = $template->get_template_vars('U_SLIDESHOW_START');
if (isset($temp)) {
$temp .= '#'.PANCHOR_NAME;
$template->assign('U_SLIDESHOW_START', $temp);
}
//stop slideshow nav button
$temp = $template->get_template_vars('U_SLIDESHOW_STOP');
if (isset($temp)) {
$temp .= '#'.PANCHOR_NAME;
$template->assign('U_SLIDESHOW_STOP', $temp);
}
//assign anchor name to template var
$template->assign('PANCHOR_NAME', PANCHOR_NAME);
return $content;
} //end function pAnchor_links
function pAnchor_picture_prefilter($content, &$smarty) {
//add the HTML page anchor tag into picture template via search string
global $template;
$search = '#'.PANCHOR_PICTURE_SEARCH_TAG.'#';
$replacement = ''.PANCHOR_PICTURE_SEARCH_TAG;
return preg_replace($search, $replacement, $content);
}
function pAnchor_slideshow_prefilter($content, &$smarty) {
//add the HTML page anchor tag into slideshow template via search string
global $template;
$search = '#'.PANCHOR_SLIDESHOW_SEARCH_TAG.'#';
$replacement = ''.PANCHOR_SLIDESHOW_SEARCH_TAG;
return preg_replace($search, $replacement, $content);
}
function pAnchor_add_anchor() {
//setup add anchor prefilters for picture.tpl and slideshow.tpl
global $template;
$template->set_prefilter('picture', 'pAnchor_picture_prefilter');
$template->set_prefilter('slideshow', 'pAnchor_slideshow_prefilter');
}
function pAnchor_adj_meta_refresh() {
//adjust the get_template_vars('page_refresh');
if (isset($temp['U_REFRESH'])) {
$temp['U_REFRESH'] = $temp['U_REFRESH'].'#'.PANCHOR_NAME;
$template->assign('page_refresh', $temp);
}
if (isset($page['slideshow'])) {
if ($page['slideshow']) {
//add CSS for pAnchor to document head
$template->append('head_elements', PANCHOR_CSS_SLIDESHOW);
//load js for pAnchor
} else {
//add CSS for pAnchor to document head
$template->append('head_elements', PANCHOR_CSS_PICTURE);
}
}
//experimental feature to auto ease scroll to pAnchor when navigating
//to picture or slideshow from another page (that does not have # in url)
if ( PANCHOR_EASE_ENABLE == true) {
$template->append('head_elements', '');
}
}
//do NOT add anchors on ADMIN side of piwigo
if (!defined('IN_ADMIN')) {
add_event_handler('render_element_content', 'pAnchor_links');
add_event_handler('loc_end_picture', 'pAnchor_add_anchor');
add_event_handler('loc_end_page_header', 'pAnchor_adj_meta_refresh');
}
?>