Web Connect How To : Show Me the Code!

 LAFOX Home How URL Maps to Code  LAFOX Design Oveview  Framework Extensions 
*Memberdirectory.prg #INCLUDE WCONNECT.H ************************************************************* DEFINE CLASS MemberDirectory AS rbPage ************************************************************* ******************************************************** ** Page() - PUBLIC - ** Show the Page ******************************************************** FUNCTION Page LOCAL loDataMan ** build page content ** using our DataLayer and HTMLTable Classes loDataMan = This.DataManager() This.Content = This.DataGrid(loDataMan) ** Merge and show the page This.PageTitle = "Member Directory" This.Merge('TemplatePage.htm') ENDFUNC &&AdminEditMeetingsList ******************************************************** ** Details() - PUBLIC - ** "Drill Down" for Member Details ******************************************************** FUNCTION Details LOCAL lcMemberID STORE [] TO lcMemberID This.PageTitle = "Member Details" lcMemberID = Request.QueryString("ID") IF This.DetailData(lcMemberID) This.Content = This.DetailHTML() ELSE ** only happens if someone messes with URL ID=0000022 ** If someone is hacking around - don't give much detail about the error This.Content = [Invalid URL] Endif This.Merge('TemplatePage.htm') ENDFUNC && Details ************************************************************ ** Helper Functions below ************************************************************ HIDDEN Function DataManager LOCAL loDataMan STORE .NULL. to loDataMan ** Remember to set procedure to DataLayer.prg additive!! loDataMan = CreateObject("DataManager") loDataMan.SQL = [Select *,IIF(ShowEmail,"More Info",SPACE(9)) as MoreInfo from ]+Site.MemberPath+"Member.dbf where ShowOnWeb=.T." loDataMan.PageSize = 20 && Defaults to 20 - for next prev pages automatically loDataMan.QueryAsNeeded() &&New Name?? Name the 3 functions loDataMan.OrderDefault="LastName" && Since we want to search - we must have an initial order set RETURN loDataMan ENDFUNC HIDDEN FUNCTION DataGrid(toData) LOCAL lcHTML LOCAL loGrid STORE .NULL. to loGrid STORE [] TO lcHTML ** Required ** Remember to set procedure to HTMLTable.prg additive!! loGrid = CreateObject("DataGrid", toData) ** Optional - defaults to ALL fields ** Creates a column object for each field ** Will create This.Col_LastName, This.Col_FirstName etc ** Col_FieldName :-) loGrid.FieldList = [LastName,FirstName,MoreInfo] ** Optional - defaults to Field Names loGrid.CaptionList = [Last Name,First Name,More Info] ** Optional ** link to the detail page - ** NOTE this expression will be evaluated - so quote the strings loGrid.Col_MoreInfo.HrefExpression = ['/MemberDirectory.Details.fox?SessionID=_70E1DIU26&ID='+MemberID] ** Optional - all columns default to sortable ** For this column no sort - they all look the same loGrid.Col_MoreInfo.Sortable = .F. loSearch = CREATEOBJECT("DataSearchBox",loGrid) && in DataGrid.prg lcHTML =[<B>]+This.PageTitle+[</B>] ; +loSearch.HTML(); +loGrid.HTMLGrid() ; +loGrid.HTMLNavBar() RETURN lcHTML ENDFUNC ******************************************************************** ** Make sure member table is open and ** locate the member record ** check that the user DID want info on the web ******************************************************************** HIDDEN FUNCTION DetailData(tcMemberID) This.OpenAndSelect("Member") LOCATE FOR (MemberID=tcMemberID) AND (ShowOnWeb=.T.) RETURN FOUND() ENDFUNC &&DetailData ************************************************************************************ ** DetaiHTML() ** Create an HTML Fragment ** For the MemberDetails ** Respect Member's wishes about phone # etc. ************************************************************************************ HIDDEN FUNCTION DetailHTML LOCAL lcHTML STORE [] TO lcHTML lcHTML = lcHTML+[<table border="2" cellpadding="2" cellspacing="2" width="100%" id="AutoNumber1">] + CRLF ** Always show the name lcHTML = lcHTML+[ <tr>] + CRLF lcHTML = lcHTML+[ <td width="100%" colspan="2" bgcolor="C0C0C0">] + CRLF lcHTML = lcHTML+[ <p align="left"><b><font size="4">] ; +FirstName+LastName + CRLF lcHTML = lcHTML+[ </font></b></td>] + CRLF lcHTML = lcHTML+[ </tr>] + CRLF ** Does Member want email published? IF ShowEmail lcHTML = lcHTML+[ <tr>] + CRLF lcHTML = lcHTML+[ <td width="10%" align="right"><b>&nbsp;&nbsp;Email&nbsp;&nbsp;</b></td>] + CRLF lcHTML = lcHTML+[ <td width="90%">&nbsp;<b>]+Email+[</b></td>] + CRLF lcHTML = lcHTML+[ </tr>] + CRLF ENDIF ** Does member want phone published? IF ShowPhone lcHTML = lcHTML+[ <tr>] + CRLF lcHTML = lcHTML+[ <td width="10%" align="right"><b>&nbsp;&nbsp;Phone&nbsp;&nbsp;</b></td>] + CRLF lcHTML = lcHTML+[ <td width="90%">&nbsp;<b>]+Phone+[</b></td>] + CRLF lcHTML = lcHTML+[ </tr>] + CRLF Endif ** Did Member put any details in WebNotes? IF NOT empty(ALLTRIM(WebNotes)) lcHTML = lcHTML+[ <tr>] + CRLF lcHTML = lcHTML+[ <td width="10%" align="right"><b>&nbsp;&nbsp;Notes&nbsp;&nbsp;</b></td>] + CRLF lcHTML = lcHTML+[ <td width="90%">&nbsp;<b>]+ALLTRIM(WebNotes)+[</b></td>] + CRLF lcHTML = lcHTML+[ </tr>] + CRLF ENDIF lcHTML = lcHTML+[</table>] + CRLF RETURN lcHTML ENDFUNC && DetaiHTML() ENDDEFINE
csCodeParser v0.9 stats: 164 lines in 0.01 seconds.