XMod Constants
New
to Version 4.0: XMod Constants can also be used in display templates.
New In Version 2.0: These are
functions built into XMod that provide your forms with additional data
about their environment. You use them like you would variables
and parameters by means of placeholders
- e.g. {XMOD_functionname}. When the form is created, all the placeholders
will be replaced by their run-time values. You can use these constants
in the form controls or you can assign them as variable values or parameter
default values. These dynamic values should not be used when naming
controls, variables, or parameters as XMod requires unique, static names
for these items.
IMPORTANT: XMod Constants
are case-sensitive.
- {XMOD_Now}
Similar to .NET's DateTime.Now
function, this will be replaced by the current date and time.
- {XMOD_Now:format}
This will
format the current date and time according to the format codes found in
the format section. Some examples:
{XMOD_Now:dd/MM/yyyy} {XMOD_Now:hh:mm:ss}
The format codes are the same codes used by .NET for formatting DateTime
variables. For more information on formatting dates and times, check out
the format attribute of the<xmod:displaydate> template
tag.
- {XMOD_UserId}
displays the current user's DotNetNuke UserId. If the user is not logged in, the value will be -1.
- {XMOD_PortalId}
is replaced with the current portal's ID
- {XMOD_PortalAlias}
is replaced with the current portal's alias
- {XMOD_PortalName}
is replaced with the current portal's name
- {XMOD_ModuleId}
is replaced with the DotNetNuke ID of the XMod Module displaying the form
- {XMOD_TabId}
is replaced with the DotNetNuke ID for the tab containing the XMod module
displaying the form.
- {XMOD_FormId}
is replaced with the unique identifier for the form currently being displayed.
- {XMOD_DatabaseVersion}
is replaced with the version number of the DotNetNuke database
- {XMOD_PortalEmail}
is replaced with the email address assigned to the current portal.
- {XMOD_PortalExpiry}
is replaced with the expiration date of the current portal
- {XMOD_HomeTabId}
is replaced with the tab ID for the current portal's home page
- {XMOD_LoginTabId}
is replaced with the tab ID for the current portal's login page
- {XMOD_LogoFile}
is replaced with the filename of the portal's logo
- {XMOD_UploadDirectory}
is replaced with the path to the portal's upload directory
- {XMOD_XModIdBefore}
is replaced with the ID of the current XMod record being edited.
This value will be (-1) if it is a new record.
- {XMOD_XModIdAfter}
is replaced with the ID of the current XMod record being edited after
the record has been saved. So, when a new record is being added, this
placeholder will be replaced with the newly created record's ID. Note
that this constant is not processed when the form is created. It is only
processed after the user clicks the "Submit" button to save
his/her changes. There is one restriction on its use: It
cannot be used as the value of a form field when a new record is being
added because the XModId isn't known until after the record has been added.
So, by the time XMod knows the ID, the record has already been saved.
The primary use for this constant is in the <redirect> tag or <email>
tag. It allows the new ID to be passed to other URL's or included in an
email notification.
- {XMOD_UserHostName}
is replaced with domain name of the user, if available.
- {XMOD_UserHostAddress}
is replaced with the user's IP address, if available
- {XMOD_UserAgent}
is replaced with the raw text from the "user-agent" HTTP header.
- {XMOD_UserBrowser}
is replaced by the text transmitted in the HTTP header to identify the
user's browser.
New to Version 3.0
- {XMOD_UserEmail} If the current user is logged-in, this tag
is replaced by the email
address on record for them.
- {XMOD_UserFirstName}
If the current user is logged-in, this
tag is replaced by the first
name on record for them.
- {XMOD_UserLastName}
If the current user is logged-in, this
tag is replaced by the Last
Name on record for them.
- {XMOD_UserFullName}
If the current user is logged-in, this
tag is replaced by the First
& Last Name on record for them.
- {XMOD_UserStreet} If the current user is logged-in, this tag
is replaced by the street
address on record for them.
- {XMOD_UserUnit} If the current user is logged-in, this tag
is replaced by the unit
component of the user's address.
- {XMOD_UserCity} If the current user is logged-in, this tag
is replaced by the city
component of the user's address.
- {XMOD_UserRegion} If the current user is logged-in, this tag
is replaced by the region
component of the user's address.
- {XMOD_UserCountry}
If the current user is logged-in, this
tag is replaced by the country
component of the user's address.
- {XMOD_UserTelephone}
If the current user is logged-in, this
tag is replaced by the user's telephone number.
- {XMOD_UserUsername}
If the current user is logged-in, this
tag is replaced by the username. For
security, this information should be used with caution.
- {XMOD_UserPassword} If the current user is logged-in, this tag
is replaced by the user's password. For
security, this information should be used with caution.
New to Version 3.2
- {XMOD_UploadDirectoryMapped} This constant will provide the file path
to the upload directory (i.e: c:\inetpub\mysite_com\Portals\0). This was
added to facilitate attaching files to an email.
New to Version 4.5
- {XMOD_UserCell}
Retrieves the user's cell/mobile phone number as specified in his/her
profile.
- {XMOD_UserFax}
Retrieves the user's FAX number if specified in the profile.
- {XMOD_UserIM}
Retrieves the users instant messaging ID/address as specified in the profile.
- {XMOD_UserPreferredLocale}
Retrieves the user's preferred locale, as specified in the profile.
- {XMOD_UserTimeZone}
Retrieves the user's time zone as specified in their profile.
- {XMOD_UserWebsite}
Retrieves the user's website, if specified in their profile.
- {XMOD_UserProfile:profile item name} Beginning with DNN 3.3 and DNN 4.3,
site administrators have the ability to define custom profile fields for
users. This XMod Constant allows you to retrieve the value in a given
field. Simply replace profile item name
with the name of the custom field.
New to Version 4.7
- {XMOD_UserDisplayName}
Available in DNN 3.3+ and 4.3+. Retrieves the display name of the user
- {XMOD_Parameter:paramName}
This constant allows you to retrieve and use parameters such as URL parameters
in your display templates (the ability is already available in forms with
the <parameters> tag). Simply replace paramName
with the name of your parameter. So for the following URL:
http://mysite.com/tabid/564/default.aspx?id=837&fname=John
{XMOD_Parameter:id} would return 837
{XMOD_Parameter:fname} would return John
- {XMOD_UrlReferrer}
This constant returns the URL (web address) of the page (known as the
referring page) which sent the visitor to the current page. Note, this
value is not always available such as when the user types the URL to the
current page into the browser address bar, when the user uses a bookmark,
or when the user is running a security program,
New to Version 5.1
- {XMOD_CurrentCulture} Returns the name of the culture that is currently selected (i.e. en-US, en-GB, es-MX, etc.)
New to Version 5.5
- {XMOD_Url} Returns the URL of the current page. NOTE: The URL is returned in its normal form. If you have enabled Friendly URL's in your site, the URL returned by this constant and URL the user sees in the Address Bar of their browser will not match.
http://mysite.com/tabid/59/default.aspx is returned by {XMOD_Url} as http://mysite.com/default.aspx?tabid=59
There are numerous ways you might choose to use these constants. A few
that come to mind are:
- Use the {XMOD_PortalId} constant in the SQL SELECT
statement you use to fill a form's listbox.
- Use the {XMOD_PortalEmail} in the <email>
form tag to send the data entered to the portal administrator's email.
- Use the {XMOD_UserHostName}, {XMOD_UserHostAddress},
{XMOD_UserAgent}, and {XMOD_UserBrowser} constants
in a technical support form, to aid in diagnosing problems.
- Use the {XMOD_Now} constant to provide a default
date value for an input box.
EXAMPLES:
<form format="custom">
<controls>
<literal>
<!--Everything
in here is HTML -->
<table
style="border: 1px blue solid; width=400px;">
<tr>
<td><h2>Welcome
To My Custom Form</h2></td>
</tr>
</table>
<table
width="400" cellpadding="3">
<tr>
<td
style="background-color:maroon; color:white;" colspan="2">
Current
Time: {XMOD_Now: dd/MM/yyyy
hh:mm}
</td>
</tr>
<tr>
<td
style="background-color:maroon; color:white;">
Your
Name:</td>
<td>
</literal>
<input
ref="UserName" width="250px" class="NormalTextBox">
<label>Your
Name</label>
</input>
<literal>
</td>
</tr>
</table>
</literal>
<hidden
ref="UserIP">{XMOD_UserHostAddress}</hidden>
<redirect
target="/Default.aspx?tabid={XMOD_HomeTabId}"
/>
</controls>
</form>