07.04.2008
Register     Login      
 
Testimonials
Powered by Testify!
DotNetNuke Platinum Benefactor

We're happy to show our support for the DotNetNuke platform and community by contributing back to the project at the highest "Platinum" level.
Testimonials
I have never given a favorable rating for a purchased module until now. I've been waiting for something to actually impress me enough to warrant a favorable review. XMod 4.5 has done so... There is no doubt that XMod 4.5 is perhaps the most useful module I've purchased in the DNN universe, because it let me configure a solution my way. It's flexible and intuitive, and performing exactly as advertised. The documentation is clear and comprehensive, which says a lot when so many modules for sale lack decent documentation or lack it altogether. But far more impressive has been Kelly's responsiveness to my questions. Unlike other module developers, Kelly has gotten back to me promptly and stayed with me until my question was handled fully. So, I'm giving XMod the highest rating and, to date, this is the only module that has received it.
Stephen Nill, Founder & Chief Executive Officer, CharityChannel.com
Buck's Tip: Code Reuse with Parameters
Location: BlogsBuck Anderson    
Posted by: Buck Anderson 2/3/2008 9:16 PM
After you have written several XMod applications, it seems you look for better, and faster, ways to make your XMod code library more reusable...

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&amp;CName=<xmod:field name="Company"/>&amp;VEID=<xmod:field name="ContactEmail"/>&amp;VID=<xmod:field name="UserID"/>&amp;CCode=<xmod:field name="PromoCode"/>&amp;LID=<xmod:field name="ListingID"/>" target="_blank"

Using parameters to create reusable code will save you a lot of time.

Happy Coding!
Buck

Copyright ©2008 Buck Anderson and DNNprofessor.com
Permalink |  Trackback

Your name:
Title:
Comment:
Security Code
Enter the code shown above in the box below
Add Comment   Cancel 
       Terms Of Use      Privacy Statement      © 2004-2008 Kelly Ford