|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
当然了,现在国内CRM厂商的产品与其说是CRM,但从至少从我的角度分析上来看,充其量只是一个大型的进销存而已了,了解尚浅,不够胆详评,这里只提技术问题yahooThissamplewilldemonstratehowtoquicklybuildasimpleYahoo!stylenavigationbarthatdisplaysthepathsauserhastakentogettoagivendirectory,andalsodisplaysatableoflinkstothesub-directoriesofthecurrentdirectory.
ThefirstthingIliketodowhenbeginninganydatabasedrivenapplicationistodesignthedatastructure.Ofcourse,oncewegetintowritingthecode,manytimescolumnsortablesneedtobeaddedormodifiedfromtheinitialdesign,buthavingadataframeworkhelpstogiveussomefocusanddirection.
DatabaseLayout
IamusinganAccess2000databaseforthisexample.YoucandefinitelyportthistoanyRDBMSeasily;justfollowthesametablearchitecture.
LetsstartbycreatinganewAccessdatabase,andnameitBread.mdb.
CreateasingletableandnameittblParents.
OpenitupinDesignModeandaddthefollowingcolumns.
*Youcanskipbuildingallthisfromscratchbydownloadingthesourcefiles.
Bread.mdb
ColumnNameDataType
AIDAutoNumber(PrimaryKey)
DirNameText
ChildDirText
ParentDirText
ChildDirDescriptMemo
DirDescriptMemo
*IfdesigningforSQLServer,maketheAIDColumnanIdentityField,withanincrementof1andmakesureallownullsisoff.
Nextwewillwanttopopulateourtablewithdata,soletmeexplainthelogicofthearchitecture.
Startbyinsertingthedatafortherootdirectoryofyourwebserver.Thiswillbespecifiedbyinsertingaforwardslash/intotheDirNamecolumn.
NextaddthedirectorybelowtheroottotheChildDircolumn(makesureyouaddtheexactdirectorynameasitappearsontheserver)
Sincethisistherootdirectory,leavetheParentDircolumnblank.
FortheChildDirDescriptColumn,youwanttoenterwhateveryouwantthetexttoreadforthelinktotheChildDirdirectorythatyoujustentered.(i.e.,ifyouenteredmusicasaChildDirName,youmaywantthelinkthatpointstomusictoalsoreadMusic,soyouenterMusicintheChildDirDescriptcolumnforthisentry.IfyouwantittoreadModernMusic,enterthat)
FortheDirDescriptcolumn,enterthetextyouwanttoappeartodescribethecurrentdirectory,whichinthiscaseistherootfolder.IusedthewordHomeasthedescriptionsothatuserswillalwaysknowthatclickingonthislinkwillbringmebacktothebeginning.
Repeatthisprocessforeachsubdirectoryyouhavebelowyourwebroot.
Note:Makesuretocreatetheactualdirectorystructureonthewebserverifitdoesnotalreadyexist.
Yourdatashouldlooksimilartothis:
Afteryoucompletethisprocessmakesureyoualsomakeentriesinthedatabaseforthedirectoriesyoujustadded.InmycaseIaddedadirectoryMusic,sonowImustaddtheappropriateFieldsforMusic.SinceMusichasaparentdirectory(Root),wemustspecifyitbyaddingaforwardslashforParentDir.
PopulatethedataforMusicandanyotherSubDirectoriesyoulike.
Youmayrefertothescreenshotbelowformyexample.
*TheChildDircolumnsshouldcontainallthedirectoriesbelowtheRoot.
TheCode
Nowthatwehavesomevaliddata,letsstartbycreatingacoupleoffunctions.Wewillhousethesefunctionsinanincludefile,namedfolderFunctions.asp.Thefirstfunctionwewantisafunctiontoreturnthecurrentphysicaldirectoryofthewebserver.Wewillusethisfunctionwhenwedoadatabaselookuptobuildtheappropriatelinksandpathhistory.InamedthisfunctionGetThisPath.
Firstthingourfunctionneedstodoisgetthecurrentfullpathfromtheserver.WewillusethePath_InfomethodoftheServerVariablescollectiontolookitup.
Sinceweonlywantthecurrentdirectoryname,wewillsplitthestringreturnedfromPath_Infoattheforwardslash,whichwillcreateanarraycontainingallthedirectoriesabovethecurrentdirectory.Thenwewillneedtoloopthrutheentirearraytopullonlythedataweneed(thecurrentdirectory).Wewillaccomplishthisbysettingourlooptoexitatthenexttothelastentryinthearray(Theverylastentrywouldbethepagenameandwedontwantthat).Thewaywedothisistotellthelooptoexecuteasmanytimesasvaluesthearrayholdsminusone.WegetthatinformationbyaskingthearrayforitsupperBounds.
Thenwewillsetthefunctionsreturnvaluetothelastentryinourloopbyoverwritingthereturnvalueineachloop,whichwillbethecurrentdirectory.However,ifthearrayisempty,itmeansweareattherootoftheserverandweneedtosetthereturnvalue</p>ASP脚本是采用明文(plaintext)方式来编写的。 |
|