I have been trying to get an answer to this by bumping a couple of threads marked solved.. so thought I would make this its own topic.
I added an add to favorites link in my nav bar as explained in this thread: http://forum.coppermine-gallery.net/index.php?topic=26315.20
It does work in adding the image to the favorites however the page reloads to an error that the selected album/file does not exist. I found a few posts about this topic, all marked solved and all offering the same mod of addfav.php:
$header_location = (@preg_match('/Microsoft|WebSTAR|Xitami/', getenv('SERVER_SOFTWARE'))) ? 'Refresh: 0; URL=' : 'Location: ';
// MOD BEGIN
$ref .= '&cat='.$_GET['cat'].'&pos='.$_GET['pos'];
// MOD END
header($header_location . $ref);
For reference those posts are: http://forum.coppermine-gallery.net/index.php?topic=32079.0 and http://forum.coppermine-gallery.net/index.php?topic=31124.0
This did not fix it for me. I am running 1.4.9 with the album_fav_boxes plugin. I did get some advice from Nibbler but not really clear to me ???
QuoteYou need to add a redirect parameter to the link, look at the built-in link to see how this works. It was added as a bugfix since this mod was posted.
I do have a test setup at http://www.folkphotography.com/prints/
username and password : test
thanks to anyone that has any advice on how to fix this or if someone can explain it a bit more detail which built in link I should be looking at to understand how to add a redirect parameter.
Just to further clarify.. the part of the code I think I need to fix is this:
if (USER_ID) {
if (!in_array($CURRENT_PIC_DATA['pid'], $FAVPICS)) {
$favorite = '<a href=addfav.php?pid=' . $CURRENT_PIC_DATA['pid'] . ' ><img src="http://www.folkphotography.com/prints/images/addlight.gif" align="middle" border="0" alt="" title="'. $lang_picinfo['addFav'] . '" /></a>';
} else {
$favorite = '<a href=addfav.php?pid=' . $CURRENT_PIC_DATA['pid'] . ' ><img src="images/remlight.gif" align="middle" border="0" alt="" title="'. $lang_picinfo['remFav'] . '" /></a>';
}
} else {
$favorite = '';
}
I found this in my displayimage.php:
$ref = $REFERER ? "&ref=$REFERER" : '';
if (!in_array($CURRENT_PIC_DATA['pid'], $FAVPICS)) {
$info[$lang_picinfo['addFavPhrase']] = "<a href=\"addfav.php?pid=" . $CURRENT_PIC_DATA['pid'] . $ref . "\" >" . $lang_picinfo['addFav'] . '</a>';
} else {
$info[$lang_picinfo['addFavPhrase']] = "<a href=\"addfav.php?pid=" . $CURRENT_PIC_DATA['pid'] . $ref . "\" >" . $lang_picinfo['remFav'] . '</a>';
}
is this the "built-in" link I should be replicating?
.. you can mark this as solved. After some more digging around I found the solution spread out in a few different threads. In case anyone cares.. the correct code to move the add button to the nav is actually
function theme_html_img_nav_menu()
{
global $CONFIG, $HTTP_SERVER_VARS, $HTTP_GET_VARS, $CURRENT_PIC_DATA, $PHP_SELF, $FAVPICS, $REFERER;
global $album, $cat, $pos, $pic_count, $lang_img_nav_bar, $lang_picinfo, $lang_text_dir, $template_img_navbar;
$cat_link = is_numeric($album) ? '' : '&cat=' . $cat;
$human_pos = $pos + 1;
$page = ceil(($pos + 1) / ($CONFIG['thumbrows'] * $CONFIG['thumbcols']));
$pid = $CURRENT_PIC_DATA['pid'];
$start = 0;
$start_tgt = "{$_SERVER['PHP_SELF']}?album=$album$cat_link&pos=$start";
$start_title = $lang_img_nav_bar['go_album_start'];
$meta_nav .= "<link rel=\"start\" href=\"$start_tgt\" title=\"$start_title\" />
";
$end = $pic_count - 1;
$end_tgt = "{$_SERVER['PHP_SELF']}?album=$album$cat_link&pos=$end";
$end_title = $lang_img_nav_bar['go_album_end'];
$meta_nav .= "<link rel=\"last\" href=\"$end_tgt\" title=\"$end_title\" />
";
if ($pos > 0) {
$prev = $pos - 1;
$prev_tgt = "{$_SERVER['PHP_SELF']}?album=$album$cat_link&pos=$prev";
$prev_title = $lang_img_nav_bar['prev_title'];
$meta_nav .= "<link rel=\"prev\" href=\"$prev_tgt\" title=\"$prev_title\" />
";
} else {
$prev_tgt = "javascript:;";
$prev_title = "";
}
if ($pos < ($pic_count -1)) {
$next = $pos + 1;
$next_tgt = "{$_SERVER['PHP_SELF']}?album=$album$cat_link&pos=$next";
$next_title = $lang_img_nav_bar['next_title'];
$meta_nav .= "<link rel=\"next\" href=\"$next_tgt\" title=\"$next_title\"/>
";
} else {
$next_tgt = "javascript:;";
$next_title = "";
}
if (USER_CAN_SEND_ECARDS) {
$ecard_tgt = "ecard.php?album=$album$cat_link&pid=$pid&pos=$pos";
$ecard_title = $lang_img_nav_bar['ecard_title'];
} else {
template_extract_block($template_img_navbar, 'ecard_button'); // added to remove button if cannot send ecard
/*$ecard_tgt = "javascript:alert('" . addslashes($lang_img_nav_bar['ecard_disabled_msg']) . "');";
$ecard_title = $lang_img_nav_bar['ecard_disabled'];*/
}
$ref = $REFERER ? "&ref=$REFERER" : '';
if (!in_array($CURRENT_PIC_DATA['pid'], $FAVPICS)) {
$favorite = '<a href=addfav.php?pid=' . $CURRENT_PIC_DATA['pid'] . $ref . ' ><img src="images/addlight.jpg" align="middle" border="0" alt="" title="'. $lang_picinfo['addFav'] . '" /></a>';
} else {
$favorite = '<a href=addfav.php?pid=' . $CURRENT_PIC_DATA['pid'] . $ref . ' ><img src="images/remlight.jpg" align="middle" border="0" alt="" title="'. $lang_picinfo['remFav'] . '" /></a>';
}
with this fix for a know bug in addfav.php
$header_location = (@preg_match('/Microsoft|WebSTAR|Xitami/', getenv('SERVER_SOFTWARE'))) ? 'Refresh: 0; URL=' : 'Location: ';
// MOD BEGIN
echo "HEADER LOCATION: $header_location<br />";
echo "REF: $ref<br />";
ob_end_flush();
exit();
// MOD END