Added an embed param for the shop cart function to use partial templates, suitable...
authorAdrian Oldham <adriann@visualthought.com.au>
Thu, 3 May 2007 00:41:47 +0000 (00:41 +0000)
committeradriann <adriann@45cb6cf1-00bc-42d2-bb5a-07f51df49f94>
Thu, 3 May 2007 00:41:47 +0000 (00:41 +0000)
site/cgi-bin/modules/BSE/UI/Shop.pm
site/templates/base.tmpl
site/templates/include/cart_sidebar.tmpl [new file with mode: 0644]

index ebe5f79..7861d43 100644 (file)
@@ -91,7 +91,7 @@ sub req_cart {
   $cust_class->enter_cart(\@cart, \@cart_prods, \%custom_state, $req->cfg); 
   $msg = '' unless defined $msg;
   $msg = escape_html($msg);
-
+  
   my %acts;
   %acts =
     (
@@ -104,7 +104,13 @@ sub req_cart {
   $req->session->{custom} = \%custom_state;
   $req->session->{order_info_confirmed} = 0;
 
-  return $req->response('cart', \%acts);
+  # intended to ajax enable the shop cart with partial templates
+  my $template = 'cart';
+  my $embed = $req->cgi->param('embed');
+  if (defined $embed and $embed =~ /^\w+$/) {
+    $template = "include/cart_$embed";
+  }
+  return $req->response($template, \%acts);
 }
 
 sub req_add {
index f22bad8..458b8c6 100644 (file)
@@ -138,27 +138,7 @@ function bse_popup_image (article_id, image_id, width, height, tag_id, image_url
             </table>
         <:iterator end dynlevel1s:>
 <:if Cfg shop sidebar_cart:>
-<table width="100%" border="0" class="sidebar_cart">
-<:if Dyncart:>
-<tr>
-  <th>Product</th><th>Units</th><th>Price</th><th>Ext.</th></tr>
-</tr>
-<:iterator begin dyncart:>
-<tr>
-  <td><a href="<:dyncartitem link:>"><:dynreplace [dyncartitem title] "((?:&[^;]*;|[^&]){15}).*" $1...:></a></td>
-  <td class="cartunits"><:dyncartitem units:></td>
-  <td class="cartprice"><:money dyncartitem retailPrice:></td>
-  <td class="cartprice"><:money dyncartitem extended:></td>
-</tr>
-<:iterator end dyncart:>
-<tr>
-  <td colspan="3">Subtotal (<:dyncarttotalunits:> items):</td>
-  <td class="cartprice"><:money dyncarttotalcost:></td>
-</tr>
-<:or Dyncart:>
-<tr><td class="emptycart">Your cart is empty</td></tr>
-<:eif Dyncart:>
-</table>
+<:include include/cart_sidebar.tmpl:>
 <:or Cfg:><:eif Cfg:>
 <:or Dynamic:>
             <:iterator begin level1:>  
diff --git a/site/templates/include/cart_sidebar.tmpl b/site/templates/include/cart_sidebar.tmpl
new file mode 100644 (file)
index 0000000..5b2d45b
--- /dev/null
@@ -0,0 +1,21 @@
+<table width="100%" border="0" id="sidebar_cart" class="sidebar_cart">
+<:if Dyncart:>
+<tr>
+  <th>Product</th><th>Units</th><th>Price</th><th>Ext.</th></tr>
+</tr>
+<:iterator begin dyncart:>
+<tr>
+  <td><a href="<:dyncartitem link:>"><:dynreplace [dyncartitem title] "((?:&[^;]*;|[^&]){15}).*" $1...:></a></td>
+  <td class="cartunits"><:dyncartitem units:></td>
+  <td class="cartprice"><:money dyncartitem retailPrice:></td>
+  <td class="cartprice"><:money dyncartitem extended:></td>
+</tr>
+<:iterator end dyncart:>
+<tr>
+  <td colspan="3">Subtotal (<:dyncarttotalunits:> items):</td>
+  <td class="cartprice"><:money dyncarttotalcost:></td>
+</tr>
+<:or Dyncart:>
+<tr><td class="emptycart">Your cart is empty</td></tr>
+<:eif Dyncart:>
+</table>
\ No newline at end of file