Aspcms Product Details page to adjust related products

Source: Internet
Author: User

Product Details page Call related products The most common application is to decorate the company's website, the designer page asked to pick up the case of designers. ASPCMS itself has this function, but can not fully meet the requirements, see the code

{aspcms:content Sort={aspcms:sortid} num=10 Order=order}         <a href= ' [Content:link] ' >                       </a>         <a href= ' [Content:link ] ">[content:title len=12]</a>{/aspcms:content}

  

This can only read the specified column of related products, each designer to do the column is obviously not too realistic, this situation can only change the program, I have made an interface here, placed in the root directory API folder

<!--#include file= ". /inc/aspcms_settingclass.asp "--><meta http-equiv=" Content-type "content=" text/html; charset=gb2312 "/><%function vbsunescape (str) Dim xx=instr (str,"% ") do while x>0vbsunescape=vbsunescape& Mid (Str,1,x-1) If LCase (Mid (str,x+1,1)) = "U" THENVBSUNESCAPE=VBSUNESCAPE&AMP;CHRW (CLng ("&h" &mid (str,x+2,4) )) Str=mid (str,x+6) ELSEVBSUNESCAPE=VBSUNESCAPE&AMP;CHR (CLng ("&h" &mid (str,x+1,2))) Str=mid (str,x+3) End Ifx =instr (str, "%") loopvbsunescape=vbsunescape&strend Function%><%dim Desginer,resdesginer = VbsUnEscape ( Request.Form ("des")) Function makeList (Desginer) Dim Rsset Rs =conn.exec ("select * FROM {prefix}content where Contentstatus=1 and Isrecommend=1 and p_author= ' "&desginer&" "," r1 ") res =" ["do While not Rs.eofres = res &" { "res = res &" "" "" ContentID "": "& RS (" ContentID ") &", "res = res &" "" "title" ":" "& RS (" title ") &" "", " res = res & "" "Indeximage" ":" "& RS (" Indeximage ") Rs. Movenextif not rs.eofThenres = res & ""}, "Elseres = res &" ""} "End ifloopres = res &"] "Rs.close:set rs=nothingmakelist = Resend Function%><%response. Write makeList (Desginer)%>

  

The API accepts the designer parameters, from the database to identify the eligible data, and then return, the foreground through Ajax (because Ajax does not support GB2312, encountered in Chinese is garbled, so the AJAX request before sending the parameters to encode, and then decode)

var $related = $ (". related");//Related product container var Desginer = $ (". Related-title"). attr ("Data-author");//query parameter Console.log ( Desginer); $.post ("/api/aspcms_api.asp", {Des:escape (Desginer)}, function (res) {var works = Json.parse (Res.slice ( Res.indexof ("["), Res.length)), var templatestr = "<ul class= ' Related-item clearfix ' >" Works.foreach (Function ( Item, index) {templatestr + = "<li><a href= '/content/?" + Item. ContentID + ". html ' ><span>" + item.title + "</span></a></li>"}) Templatestr + = "</ul>" $ Related.html (TEMPLATESTR);})

  

The foreground gets data through Ajax and plugs into the container

Backstage also to do some settings, first to the "Content Maintenance", "Content parameter Management" column add parameters, here control type Select Single, in the alternative Content input designer, enter the product when remember to choose the case designer. Here's a question, if you edit the parameters again, the "alternate content" area is not displayed, so you need to change the/_content/_spec/aspcms_specedit.asp?action=update&id=5 file

Remove the Display:none and make a judgment on the type of control, not all cases where "alternative" is displayed

<script type= "Text/javascript" >if (<%=speccontroltype%>!==6) {document.getElementById ("trSpecOptions") ). style.display= "None";} </script>

  

Judging the Speccontroltype field, the "alternative" is displayed only in the case of a single radio

The value output of the "alternate content" is changed from <%=SpecOptions%> to <%=decode (specoptions)%>, and the new "content parameter" is encoded when it is saved, and is decoded here.

Last step, modify the Save function

Sub Editspecsavedim Sql,rsobjspecfield=filterpara (GetForm ("Specfield", "POST") Specid=filterpara (GetForm ("SpecID" , "POST")) Specoptions=filterpara (GetForm ("Specoptions", "post")) Specdiversification=filterpara (GetForm (" Specdiversification "," post ")) Speccontroltype=filterpara (GetForm (" Speccontroltype "," post ")) Specname=filterpara ( GetForm ("Specname", "post")) Speccategory=filterpara (GetForm ("Speccategory", "post")) Specorder=filterpara (getForm ("Specorder", "post")) Specnotnull=filterpara (GetForm ("Specnotnull", "post")) Specoptions = Encode (specoptions)//encode specoptions if Specnotnull = "on" thenspecnotnull = Trueelsespecnotnull = FalseEnd Ifsql = "Select * from {prefix}specset where specid=" & Amp Specidset Rsobj=conn. Exec (SQL, "r1") sql = "Update {prefix}specset set specname= '" &SpecName& "', speccategory= '" &speccategory & "', specoptions= '" &SpecOptions& "', specorder=" &SpecOrder& ", specnotnull=" &specnotnull & the "where specid=" &specid//sql statement is no longer committed speccontroltype, which is resubmitted by default, causingSpeccontroltype becomes empty conn.exec sql, "EXE" Alertmsgandgo "Modify succeeded", "aspcms_spec.asp" End Sub 

  

This allows you to add a designer directly to the content parameter management interface.

Aspcms Product Details page to adjust related products

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.