forum.coppermine-gallery.net
Support => cpg1.4.x Support => Older/other versions => cpg1.4 plugins => Topic started by: stevenp on October 15, 2007, 01:07:50 am
-
hello
I want to show the buy-button of the photo shop modul next to every thumbnail in my albums. How can i get this?
greetings steven
-
not related to the modpack... moving to the plugin board
-
hello
any ideas? i want to show the buy-button of the photo shop modul next to every thumbnail in my albums. someone there, who knows what to change?
steven
-
http://coppermine-gallery.net/demo/cpg14x/docs/faq.htm#lamesupport
-
not possible (or better: it's not possible without modifying core code and some more heat on the server -> 1 more query per thumb)
in functions.inc.php find (within function display_thumbnails):
if you use the modpack
$thumb_list[$i]['pheight'] = $row['pheight'];
if you use a standard coppermine
$thumb_list[$i]['aid'] = $row['aid'];
below add
//photo_shop plugin hook
$thumb_list[$i] = CPGPluginAPI::filter('display_thumbs',$thumb_list[$i]);
in the plugins codebase.php find
// Some filters
$thisplugin->add_filter('thumb_list','photoshop_add_item');
below add
(this is the slightly modified function for displaying the add item dropdown on the intermediate view and the filter call)
$thisplugin->add_filter('display_thumbs','photoshop_thumb_add_item');
//add an item to the cart while viewing the thumb list
function photoshop_thumb_add_item($pic_data){
global $CONFIG, $SHOP_CONFIG, $lang_photoshop, $album;
$html = "";
$added = "";
$event = isset($_POST['event']) ? $_POST['event'] : null;
//price override
//if the shop is disabled to show for that album we return $pic_data
//also we check if an override price is set
$results = cpg_db_query("SELECT * FROM {$CONFIG['TABLE_SHOP_PRICES']} WHERE aid={$pic_data['aid']}");
while ($temp_data = mysql_fetch_array($results)) {
if($temp_data['gid']=='-1') return $pic_data;
$SHOP_CONFIG[$temp_data['gid']]['price']=$temp_data['price'];
}
mysql_free_result($results);
switch ($event) {
case 'add_item':
if(isset($_POST['pid']))
$added = '<center><font color="red">'.$lang_photoshop['added']."!</font></center>";
$duplicate=photoshop_deep_in_array($_POST['pid'],$_POST['item_id'],$_SESSION['photoshop']['cart']);//search array if item is already in cart.. then ++ amount of that item
if(is_numeric($duplicate)){ // only add 1 item if it's for the CD
if ($_SESSION['photoshop']['cart'][$duplicate]['id'] != "CD"){
++$_SESSION['photoshop']['cart'][$duplicate]['amount'];
} else {
//break;
}
} else {
$_SESSION['photoshop']['cart'][] = array(
'pid' => $_POST['pid'],
'id' => $_POST['item_id'],
'amount' => '1',
'aid' => $pic_data['aid'],
);
}
$cookie_data = base64_encode(serialize($_SESSION['photoshop']['cart']));
setcookie($CONFIG['cookie_name'] . '_cart', $cookie_data, time() + 86400 * 30, $CONFIG['cookie_path']);
break;
}
//loop through the items and create forms
$html .= "<select name=\"item_id\" class=\"listbox_lang\">";
foreach($SHOP_CONFIG as $key => $value) {
if ($value['type'] == 'photo') {
if ($value['price'] != 0) {
$html.="<option value=\"{$value['id']}\">{$value['name']} - {$lang_photoshop['USD']}{$value['price']}</option>";
}
} elseif ($value['type'] == 'cd') {
$cd = true;
}
}
$html .= ($cd) ? "<option value=\"CD\">{$lang_photoshop['CD']}</option>" : '';
$html .="</select>";
($album == 'search') ? $referer = "thumbnails.php?album={$pic_data['aid']}" : $referer = null;
$shop_data = <<<EOT
<table class="shop_table">
<tr>
<td>
<form action="{$referer}" method="post">
{$added}{$lang_photoshop['buy']} {$html}
<input type="hidden" value="{$pic_data['pid']}" name="pid" />
<input type="hidden" value="add_item" name="event" />
<input type="submit" value="{$lang_photoshop['send']}" class="comment_button" />
</form>
</td>
</tr>
</table>
EOT;
$pic_data['caption'] = $shop_data.$pic_data['caption'];
$referer = ($_SERVER['PHP_SELF'] . (isset($_SERVER['QUERY_STRING']) && $_SERVER['QUERY_STRING'] ? '?' . $_SERVER['QUERY_STRING'] : ''));
if ($added) {
//this is not nice.. but the menu updates before the content. So if you add an item, the basket count can't match
// -> we have to refresh the page twice... can be removed but than the counter is wrong till the user manually reloads
photoshop_refresh($referer);
echo $added; // redundant ... while refreshing display 'item added'
exit;
}
return $pic_data;
}
-
Many thanks at you, stramm!!!
I filled in the code for codebase.php and get this error
"Fatal error: Cannot redeclare photoshop_start() (previously declared in /homepages/17/d124044955/htdocs/cpg/plugins/photo_shop/codebase.php:138) in /homepages/17/d124044955/htdocs/cpg/plugins/photo_shop/codebase.php on line 147"
what's wrong?
In my function.inc.php i don't have a code like this "$thumb_list[$i]['pheight'] = $row['pheight'];", so I don't know where to put this
"//photo_shop plugin hook
$thumb_list[$i] = CPGPluginAPI::filter('display_thumbs',$thumb_list[$i]);"
I hope, i'm not to annoyingly. I only have these problems with my shop and it's really important for me.
Steven
-
yah.. OK, I've updated above instructions... you only have this part if you use the modpack, so it's my bad
The cause for
Fatal error: Cannot redeclare photoshop_start()
is that by accident I've copied two functions in the above instr. where there should be only one.
Restart modding using a fresh copy of codebase.php and all should be good.
-
Okay,
the code-tags are inserted. All works, but I still got no cartfuction next to my thumbnails. Did i understand something wrong?
Many thanks for all your help and work.
Steven
-
yeppers, try again to add the huge block above with the function. Tried it on an umodded CPG and it works smooth as butter
-
hippyyeyahhh,
it works!!!!!!!!!!! GREAT... Thanks a lot!!!!
Please have a last look and try to use ist. After using the add to cart-button. My whole site appears in my coppermine(frame).
Steven