relatedproduct.jsp
来自「实现一个网络购物」· JSP 代码 · 共 259 行
JSP
259 行
<mm:node number="<%= productId %>"
><% productHref = "index.jsp?page=bestel&u=" + productId;
%><table width="100%" cellspacing="0" cellpadding="0">
<tr>
<td style="padding-left:3px;padding-right:3px;">
<strong><mm:field name="title" /></strong><br>
<mm:field name="intro" />
</td>
</tr>
</table><%
// ************************************* Show the image, price and shoppingcart *************
%><table width="100%" cellspacing="0" cellpadding="0" background="<mm:related path="posrel,images" constraints="posrel.pos=1"
><mm:node element="images"><mm:image template="s(195x80)" /></mm:node
></mm:related
>" style="background-position:bottom left;background-repeat:no-repeat;">
<tr>
<td rowspan="2" width="45%" height="100px">
<mm:field name="type"
><mm:isnotempty
><mm:compare value="standaard" inverse="true"
><img style="float:left;margin-left:70px;margin-top:10px;" src="media/<mm:write />.gif"></mm:compare
></mm:isnotempty
></mm:field>
</td>
<td class="middle" style="padding-right:3px;">
<%@include file="../includes/relatedprice.jsp" %>
</td>
</tr>
<tr><%@include file="../includes/relatedshoppingcart.jsp"%></tr>
<tr><td class="titlebar" colspan="2"><img src="media/spacer.gif" height="1" width="1" border="0" alt=""></td></tr>
</table>
<table width="100%" cellspacing="0" cellpadding="0"><%
// ************************************* Show discounts (if any) *************************************
%><mm:related path="posrel,discounts"
><mm:field name="discounts.startdate" jspvar="startdate" vartype="String" write="false"
><mm:field name="discounts.enddate" jspvar="enddate" vartype="String" write="false"><%
if(now<=Long.parseLong(enddate)) { // do not show old discounts
%><tr><td style="padding:3px;">
<strong
><mm:field name="discounts.title" jspvar="discounts_title" vartype="String" write="false"
><%= discounts_title.toUpperCase()
%></mm:field
></strong><br>
<mm:field name="discounts.body" /><br>
This offer is valid <%
if(Long.parseLong(startdate)>=now) { // only show startdate if discount is not started
%> from <%
timestr = startdate; %><%@include file="../includes/timestring.jsp" %><%
}
%> till <%
timestr = enddate; %><%@include file="../includes/timestring.jsp" %>.
</tr></td>
<tr><td><img src="media/spacer.gif" height="4" width="1" border="0" alt=""></td></tr>
<tr><td class="titlebar"><img src="media/spacer.gif" height="1" width="1" border="0" alt=""></td></tr><%
}
%></mm:field
></mm:field
></mm:related
><%
// *** the combi-discount: the source product ***
%><mm:related path="discountrel,productgroups"
><mm:field name="discountrel.startdate" jspvar="startdate" vartype="String" write="false"
><mm:field name="discountrel.enddate" jspvar="enddate" vartype="String" write="false"><%
if(now<=Long.parseLong(enddate)) { // do not show old discountrel
%><tr><td style="padding:3px;">
<strong
><mm:field name="discountrel.title" jspvar="discountrel_title" vartype="String" write="false"
><%= discountrel_title.toUpperCase()
%></mm:field
></strong><br>
<mm:field name="discountrel.body" /><br>
<mm:field name="productgroups.number" jspvar="pools_number" vartype="String" write="false"
><mm:list nodes="<%= pools_number %>" path="productgroups,posrel,products" orderby="posrel.pos" directions="UP"
constraints="<%= "products.number != '" + productId + "'" %>"
><mm:first>This offer is valid if you <mm:remove referid="size"
/><mm:size id="size"
><mm:compare referid="size" value="1">also order this article</mm:compare
><mm:compare referid="size" value="1" inverse="true"> also order one of the next articles</mm:compare
></mm:size
> : </mm:first
><mm:first inverse="true">, </mm:first
><a class="nav" href="<mm:url referids="portal,page" page="index.jsp"><mm:param name="u"><mm:field name="products.number" /></mm:param></mm:url
>"><mm:field name="products.title" /></a><mm:last>.</mm:last
></mm:list
></mm:field> This offer is valid <%
if(Long.parseLong(startdate)>=now) { // only show startdate if discount is not started
%> from <%
timestr = startdate; %><%@include file="../includes/timestring.jsp" %><%
}
%> till <%
timestr = enddate; %><%@include file="../includes/timestring.jsp"
%>.
</tr></td>
<tr><td><img src="media/spacer.gif" height="4" width="1" border="0" alt=""></td></tr>
<tr><td class="titlebar"><img src="media/spacer.gif" height="1" width="1" border="0" alt=""></td></tr><%
}
%></mm:field
></mm:field
></mm:related
><%
// *** the combi-discount: the target product ***
%><mm:list path="products1,discountrel,productgroups,posrel,products2"
constraints="<%= "products2.number = '" + productId + "' AND products1.number != '" + productId + "'" %>"
><mm:field name="discountrel.startdate" jspvar="startdate" vartype="String" write="false"
><mm:field name="discountrel.enddate" jspvar="enddate" vartype="String" write="false"><%
if(now<=Long.parseLong(enddate)) { // do not show old discountrel
%><tr><td style="padding:3px;">
<strong
><mm:field name="discountrel.title" jspvar="discountrel_title" vartype="String" write="false"
><%= discountrel_title.toUpperCase()
%></mm:field
></strong><br>
<mm:field name="discountrel.body" /><br>
Buy this product and get a free <a class="nav" href="<mm:url referids="portal,page" page="index.jsp"
><mm:param name="u"><mm:field name="products1.number" /></mm:param></mm:url
>"><mm:field name="products1.title" /></a>.
This offer is valid<%
if(Long.parseLong(startdate)>=now) { // only show startdate if discount is not started
%> from <%
timestr = startdate; %><%@include file="../includes/timestring.jsp" %><%
}
%> till <%
timestr = enddate; %><%@include file="../includes/timestring.jsp"
%>.
</tr></td>
<tr><td><img src="media/spacer.gif" height="4" width="1" border="0" alt=""></td></tr>
<tr><td><img src="media/spacer.gif" height="1" width="1" border="0" alt=""></td></tr><%
}
%></mm:field
></mm:field
></mm:list><%
// ************************************* Show the thumbnails ********************************
%><%
imageId = "";
offsetId = "";
int totalNumberOfThumbs = 0;
boolean thisIsNotFirst = false;
%><mm:list nodes="<%= productId %>" path="products,posrel,images"
orderby="posrel.pos" directions="UP" constraints="posrel.pos > 1"
><mm:field name="images.number" jspvar="images_number" vartype="String" write="false"><%
if(thisIsNotFirst) {
imageId += ",";
} else {
offsetId = images_number;
}
thisIsNotFirst = true;
imageId += images_number;
totalNumberOfThumbs++;
%></mm:field
></mm:list
><mm:list nodes="<%= productId %>" path="products,posrel,attachments"
orderby="posrel.pos" directions="UP"
><mm:field name="attachments.number" jspvar="attachments_number" vartype="String" write="false"><%
if(thisIsNotFirst) {
imageId += ",";
} else {
offsetId = attachments_number;
}
thisIsNotFirst = true;
imageId += attachments_number;
totalNumberOfThumbs++;
%></mm:field
></mm:list><%
String slideshowUrl = "templates/myshop_slideshow.jsp?w=" + "&u=" + productId + "&o=" + offsetId;
String previousImage = "-1";
String nextImage = "-1";
String thisImage = "";
String otherImages = "";
int totalNumberOfImages = 1;
int thisImageNumber = 1;
int thisThumbNailNumber = 0;
int numberInRow = 5;
while(thisThumbNailNumber<totalNumberOfThumbs) {
if(thisThumbNailNumber==0) {
%><tr><td><a name="thumbs"></a><img src="media/spacer.gif" height="8" width="1" border="0" alt=""></td></tr>
<tr><td class="titlebar"><img src="media/spacer.gif" height="1" width="1" border="0" alt=""></td></tr>
<tr><td style="padding:3px;">
<img src="media/spacer.gif" height="8" width="1" border="0" alt="">
</td></tr>
<tr><td>
<table cellspacing="0" cellpadding="0" width="100%"><tr><%
}
if(thisThumbNailNumber%numberInRow!=0) {
%><td width="16"><img src="media/spacer.gif" height="1" width="16" border="0" alt=""></td><%
}
%><td class="thumbnailparent" width="<%= 100/numberInRow %>%">
<table cellspacing="0" cellpadding="0" class="thumbnail">
<tr><td class="thumbnail">
<%@include file="../includes/splitimagelist.jsp"
%><a href="#" onClick="javascript:launchCenter('<%= slideshowUrl %>&i=<%= imageId %>', 'center', 555, 740);setTimeout('newwin.focus();',250);">
<mm:listnodes type="images" constraints="<%= "number='" + thisImage + "'" %>">
<img src="<mm:image template="s(32x54)" />" border="0" alt="">
</mm:listnodes
><mm:listnodes type="attachments" constraints="<%= "number='" + thisImage + "'" %>"
><mm:field name="filename" jspvar="attachments_filename" vartype="String" write="false"><%
if(attachments_filename.indexOf(".pdf")>-1){
%><img src="media/pdf.gif" alt="" border="0"><%
} else if(attachments_filename.indexOf(".doc")>-1){
%><img src="media/word.gif" alt="" border="0"><%
} else if(attachments_filename.indexOf(".xls")>-1){
%><img src="media/xls.gif" alt="" border="0"><%
} else if(attachments_filename.indexOf(".ppt")>-1){
%><img src="media/ppt.gif" alt="" border="0"><%
} else if(attachments_filename.indexOf(".mp3")>-1){
%><img src="media/mp3.gif" alt="" border="0"><%
} else if(attachments_filename.indexOf(".mpeg")>-1||attachments_filename.indexOf(".mpg")>-1){
%><img src="media/mpg.gif" alt="" border="0"><%
} else if(attachments_filename.indexOf(".swf")>-1){
%><img src="media/flash.gif" alt="" border="0"><%
} else {
%><img src="media/download.gif" alt="" border="0"><%
}
%></mm:field
></mm:listnodes
></a>
</td></tr>
</table>
<a class="nav" href="#" onClick="javascript:launchCenter('<%= slideshowUrl %>&i=<%= imageId
%>', 'center', 550, 740)"><mm:node number="<%= thisImage %>"><mm:field name="title" /></mm:node></a>
</td><%
imageId = nextImage;
thisThumbNailNumber++;
if(thisThumbNailNumber%numberInRow==0) { %></tr>
<tr><td colspan="<%= (numberInRow*2)-2 %>"><img src="media/spacer.gif" height="16" width="1" border="0" alt=""></td></tr>
<tr><%
}
}
if(thisThumbNailNumber>0) {
while(thisThumbNailNumber%numberInRow!=0) {
thisThumbNailNumber++;
%><td width="16"><img src="media/spacer.gif" height="1" width="16" border="0" alt=""></td>
<td><img src="media/spacer.gif" height="1" width="1" border="0" alt=""></td><%
}
%></tr></table>
</td></tr>
<tr><td><img src="media/spacer.gif" height="4" width="1" border="0" alt=""></td></tr><%
} %><%
// ************************************* Show articles ********************************
%><mm:remove referid="thumbnailsfound"
/><mm:list nodes="<%= productId %>" path="products,posrel,articles" orderby="posrel.pos" directions="UP">
<tr><td><a name="<mm:field name="articles.number" />"></a><img src="media/spacer.gif" height="8" width="1" border="0" alt=""></td></tr>
<tr><td class="titlebar"><img src="media/spacer.gif" height="1" width="1" border="0" alt=""></td></tr>
<tr><td style="padding:3px;">
<strong><mm:field name="articles.title" jspvar="articles_title" vartype="String" write="false"
><%=articles_title.toUpperCase()
%></mm:field></strong><br>
<mm:field name="articles.intro" />
</td>
</tr>
<mm:last><tr><td><img src="media/spacer.gif" height="4" width="1" border="0" alt=""></td></tr></mm:last
></mm:list>
</table>
</mm:node>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?