After you have written several XMod applications, it seems you look for better ways to make your XMod code library more reusable.
Here is a tip on using parameters.
There are certain values that most forms have in common. Instead of entering these values throughout your code, use parameters.
Here is an example:
You begin by adding parameters to your form.
<parameters>
<parameter name="iDir" alias="imageDir" default="LinkImages/"></parameter>
<parameter name="dURL" alias="domainURL" default="http://yourdomain.com"></parameter>
<parameter name="sEmail" alias="SiteEmail" default="someone@yourdomain.com"></parameter>
<parameter name="smtpServ" alias="smtpMailServer" default="mail.yourdomain.com"></parameter>
<parameter name="sSubject" alias="EmailSubject" default="Your Directory Listing"></parameter>
<parameter name="redir" alias="RedirectUrl" default="Your redirect URL"></parameter>
</parameters>
By using parameters, if you have a certain chunk of code that you want to reuse on another form, you can simply grab a section like this:
<email target="{ContactEmail}" from="{SiteEmail}" subject="{EmailSubject}" smtpserver="{smtpMailServer}" sendrule="add">
or
<redirect target="{RedirectUrl}" />
Here is another example of passing values to a form:
By placing parameters in the called form, you can then accept values that are passed from a template.
<parameters>
<parameter name="CName" alias="CName" default=""></parameter>
<parameter name="CCode" alias="CCode" default=""></parameter>
<parameter name="VEID" alias="VEID" default=""></parameter>
<parameter name="VID" alias="VID" default=""></parameter>
<parameter name="LID" alias="LID" default=""></parameter>
</parameters>
The code in a template may look something like this:
a target="_blank" href="/Default.aspx?tabid=1&CName=<xmod:field name="Company"/>&VEID=<xmod:field name="ContactEmail"/>&VID=<xmod:field name="UserID"/>&CCode=<xmod:field name="PromoCode"/>&LID=<xmod:field name="ListingID"/>" target="_blank"
Using parameters to create reusable code will save you a lot of time.
Buck Anderson's DotNetNuke Training, Video Training, and Internet Marketing Resource Center DNNprofessor.com. Free tips to
improve your business with DotNetNuke, XMod, website design techniques, and proven
unconventional Internet Marketing Solutions that attract the attention of today's
savvy Internet buyer at DNNprofessor.com. © 2008 Jive Media Group LLC and Buck Anderson.
All Rights Reserved. Reproduction without permission prohibited.
|