You are here:   Satellite Extreme
  |  Login

Netism Satellite Extreme (NSE) 1.7 - Complete Reference

This page contains reference and sample code only. For real world usage templates, please visit the Sample Template Library.
File System
Security
Only folders and files under the running portal are allowed access. Path must start with "/" and must not contains "..". This prevents directory traversal attack.
Reference Path
All paths must be specified using absolute paths relative to the portal folder.
For example, if your DNN installation is on c:\dnn and your portalID is 2, then:

/news.txt would be translated to c:\dnn\portals\2\news.txt
/images/icons would be translated to c:\dnn\portals\2\images\icons
Query
Database
NSE uses the same connection string defined in web.config. In the cases of external data sources, it uses the connection string you specific.
Security
SQL Injection:
NSE SQL API and data access were designed to guard against SQL Injections. It ensures input parameters are properly encoded and escaped.

Read Only Queries:
Data access for NSE is always read only. Query with any data/schema changes keyword or comments would be denied. In case the module edit access is compromised, intruders can't cause any damage/changes to the database.
Selecting data
Support complete select query syntax: where, recursive CTE queries, sub-queries, in-line tables, table left joins, right join, cross join, group by, having, order by, pivoting, CLR procedures and functions etc.
Variables
Query can include variables such as $module.moduleID and $user.userID. So that you can define a generic query and run across many modules and users.
Javascript
NSE allows Javascript to be seperated. It's written to the page prior to the templated code, and must include the script tag. It's saved in a text file, so you can quickly edit it with an external editor.
Style
NSE allows styles to be seperated. It's written to the page prior to the templated code, and must include the style tag. It's saved in a text file, so you can quickly edit it with an external editor.
Template
NSE allows template to be seperated. It's saved in a text file, so you can quickly edit it with an external editor.

It's powered by a template engine called NVelocity, which allows variables, athrimetic, conditional and loop expressions.
See Velocity Template Language for details.
Notes
Some quick notes or documentation. It's stored in the database, and it's not written to the page.

Variables
DNN objects | ASP.NET objects | Utility objects | Primitive types | Data structures | External resources

Note: the sign -> indicates code output, it's not a part of the code.

DNN objects
$portal
References the DotNetNuke.Entities.Portals.PortalInfo object, properties are case-sensitive. Available properties:

$portal.PortalID, $portal.PortalName, $portal.LogoFile, $portal.FooterText, $portal.ExpiryDate, $portal.UserRegistration, $portal.BannerAdvertising, $portal.AdministratorId, $portal.Currency, $portal.HostFee, $portal.HostSpace, $portal.PageQuota, $portal.UserQuota, $portal.AdministratorRoleId, $portal.AdministratorRoleName, $portal.RegisteredRoleId, $portal.RegisteredRoleName, $portal.Description, $portal.KeyWords, $portal.BackgroundFile, $portal.GUID As Guid, $portal.PaymentProcessor, $portal.ProcessorUserId, $portal.ProcessorPassword, $portal.SiteLogHistory, $portal.Email, $portal.AdminTabId, $portal.SuperTabId, $portal.Users, $portal.Pages, $portal.SplashTabId, $portal.HomeTabId, $portal.LoginTabId, $portal.UserTabId, $portal.DefaultLanguage, $portal.TimeZoneOffset, $portal.HomeDirectory, $portal.Version
$tab
References the DotNetNuke.Entities.Tabs.TabInfo object, properties are case-sensitive. Available properties:

$tab.TabID, $tab.TabOrder, $tab.PortalID, $tab.TabName, $tab.AuthorizedRoles, $tab.IsVisible, $tab.ParentId, $tab.Level, $tab.IconFile, $tab.AdministratorRoles, $tab.DisableLink, $tab.Title, $tab.Description, $tab.KeyWords, $tab.IsDeleted, $tab.Url, $tab.SkinSrc, $tab.ContainerSrc, $tab.TabPath, $tab.StartDate, $tab.EndDate, $tab.HasChildren, $tab.RefreshINSErval, $tab.PageHeadText, $tab.IsSecure, $tab.SuperTabIdSet
$module
References the DotNetNuke.Entities.Modules.ModuleInfo object, properties are case-sensitive. Available properties:

$module.PortalID, $module.TabID, $module.TabModuleID, $module.ModuleID, $module.ModuleDefID, $module.ModuleOrder, $module.PaneName, $module.ModuleTitle, $module.AuthorizedEditRoles, $module.CacheTime, $module.AuthorizedViewRoles, $module.Alignment, $module.Color, $module.Border, $module.IconFile, $module.AllTabs, $module.Visibility, $module.AuthorizedRoles, $module.IsDeleted, $module.Header, $module.Footer, $module.Start, $module.End, $module.ContainerSrc, $module.DisplayTitle, $module.DisplayPrint, $module.DisplaySyndicate, $module.InheritViewPermissions, $module.DesktopModuleID, $module.FolderName, $module.FriendlyName, $module.Description, $module.Version, $module.IsPremium, $module.IsAdmin, $module.ModuleName, $module.SupportedFeatures, $module.CompatibleVersions, $module.Dependencies, $module.Permissions, $module.DefaultCacheTime, $module.ModuleControlId, $module.ControlSrc, $module.ControlType, $module.ControlTitle, $module.HelpUrl, $module.SupportsPartialRendering, $module.ContainerPath, $module.PaneModuleIndex, $module.PaneModuleCount, $module.IsDefaultModule, $module.AllModules
$user
Available if the user is login. References the DotNetNuke.Entities.Users.UserInfo object, properties are case-sensitive. Available properties:

$user.UserID, $user.Username, $user.DisplayName, $user.FullName, $user.Email, $user.PortalID, $user.IsSuperUser, $user.AffiliateID, $user.Membership, $user.Roles, $user.RolesHydrated
$profile
Available if the user is login. A Hashtable of user profile properties
string $profile.Get(string name) 
ASP.NET objects
$qs
Retrieve data from the Request.QueryString collection.
string $qs.Get(string name)Url: /some.aspx?a=1&b=2&c=3
$qs.Get("b") -> 2
int $qs.Count$qs.Count -> 3
string[] $qs.Keys #foreach ( $q in $qs.Keys )
  $q |
#end
-> a | b | c |

#foreach ( $q in $qs.Keys )
  $qs.Get($q) |
#end
-> 1 | 2 | 3 |
$form
Retrieve data from the Request.Form collection.
string $form.Get(string name)Post coNSEnt: a=1&b=2&c=3
$form.Get("b") -> 2
int $form.Count$form.Count -> 3
string[] $form.Keys #foreach ( $f in $form.Keys )
  $f |
#end
-> a | b | c |

#foreach ( $f in $form.Keys )
  $form.Get($f) |
#end
-> 1 | 2 | 3 |
$cookie
Retrieve cookies from the Request.Cookies collection.
string $cookie.Get(string name)Cookies: a=1;b=2;c=3;
$cookie.Get("b") -> 2
int $cookie.Count$cookie.Count -> 3
string[] $cookie.Keys #foreach ( $c in $cookie.Keys )
  $c |
#end
-> a | b | c |

#foreach ( $c in $cookie.Keys )
  $cookie.Get($c) |
#end
-> 1 | 2 | 3 |
$page
Using the Page.Items collection to store cached objects. It's only good for the page request.
Different module instances on the same page can share same data, with possibly different display logic.
For example, if you need to display news article in different modules according to their categories,
then you can select all the articles, save them in $page. Then just filter the categories in the
templates. It improves performance by reducing database connections and processing.
void $page.Set(string name, object value)$page.Set("news", $rows)
object $page.Get(string name) $news = $page.Get("news")
void SetTitle(string title)$page.SetTitle($newtitle)
void SetMetaKeywords(string keywords)$page.SetMetaKeywords( $row.Get("Keywords") )
void SetMetaDescription(string description)$page.SetMetaDescription( $row.Get("Description") )
void Redirect(string url)$page.Redirect("/thankyou.aspx")
$session
Using the Session collection to store cached objects.
Works like $page, but it's good across different page requests as long as they are in the same session.
void $session.Set(string name, object value)$session.Set("news", $rows)
object $session.Get(string name) $news = $session.Get("news")
Utility objects
$visitor
Retrieving the location and browser information of the current visitor
$visitor.Location.CountryCode $visitor.Init()
country: $visitor.Location.CountryName ($visitor.Location.CountryCode)
ip: $visitor.Client.IP
browser: $visitor.Client.UserAgent
referer: $visitor.Client.Referrer

-> country: United States (US)
-> ip: 127.0.0.1
-> browser: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.11) ...
-> referer: http://somesite.com/somepage.aspx
$visitor.Location.CountryName
$visitor.Client.IP
$visitor.Client.UserAgent
$visitor.Client.Referrer
$proxy
Setting the proxy server to be used for web access.
void Configure(string url)
void Configure(string url, bool isDefault)
void Configure(string url, string username, string password)
$parser
Convert any types to string, int, double, bool or DateTime. Exceptions would be thrown if the type is unconvertable.
string $parser.getString(object obj)$parser.getString(123) -> "123"
int $parser.getInt(object obj)$parser.getInt("123") -> 123
double $parser.getDouble(object obj)$parser.getDouble("123.456") -> 123.456
bool $parser.getBool(object obj)$parser.getBool("false") -> false
DateTime $parser.getDateTime(object obj)$parser.getDateTime("1/1/2008") -> 1/1/2008 12:00:00 AM
$text
Encoding or Decoding for Html or Url.
string $text.HtmlDecode(string html) 
string $text.HtmlEncode(string html) 
string $text.UrlDecode(string url) 
string $text.UrlEncode(string url) 
$regex
Matching Regular Expression against a Url or string. Returns an ArrayList of Hash objects.
ArrayList $regex.Match(string str, string exp) #set ( $str = '<b r=1>a</b><b r=2>b</b><b r=3>c</b>' )
#set ( $exp = '<b r=(?<ref>[^>]*)>(?<txt>[^<]*)</b>' )

#set ( $matches = $regex.Match($str, $exp) )

#foreach ( $match in $matches )
  #foreach ( $k in $match.Keys )
    $k = $match.Get( $k ),
  #end
  |
#end

-> ref = 1, txt = a, | ref = 2, txt = b, | ref = 3, txt = c, |

Note: the "=" sign would just get priNSEd. It has to be in #set in order to be a variable assignment.
ArrayList $regex.MatchUrl(string url, string exp)Works like $regex.Match, but gets the coNSEnt from a web page.
$xml
XML loading and parsing.
string $xml.Xslt(string urlXml, string urlXsl) $xml.Xslt("data.xml", "style.xsl")
XmlTree $xml.LoadXml(string xml) 
XmlTree $xml.LoadFile(string path) 
XmlTree $xml.LoadUrl(string url) 
XmlTree
Nodes traversing and XPath selecting. This object can only be obtained from the $xml methods.
XNodes GetNodes(string xpath) 
XNode GetNode(string xpath) 
object GetValue(string xpath) 
object GetAttribute(string xpath, string att) 
XNodes
Holds a collection of Node. It implements IEnumerator and IEnumerable. This object can only be obtained from the XmlTree methods.
int Count 
XNode Get(int idx) 
void Remove(int idx)
void Add(XNode node)
IEnumerator GetEnumerator()
void Reset()
object Current
bool MoveNext()
XNode
Holds a Xml element and its children collection. This object can only be obtained from the XmlTree or XNodes methods.
Hash Att 
XNodes Nodes 
XNode Get(int idx) 
string Name 
string Value 
Primitive types
$guid
Returns a unique identifier $guid
-> 842976fa-af10-4133-a24e-4af17456a1e3
$now
DateTime information from DateTime.Now.

$now and $parser.getDateTime() together provides extensive DateTime manipulations. All members of the .NET DateTime structure are supported.

See DateTime structure at MSDN
$now
-> holds the current date and time.

#set ( $newyear = $parser.getDateTime('1/1/2008') )
$newyear
-> 1/1/2008 12:00:00 AM

#set ( $JanLast = $parser.getDateTime('1/31/2008') )
$JanLast
-> 1/31/2008 12:00:00 AM

$JanLast.Subtract( $newyear ).Days
-> 30

#set ( $OneYearLater = $JanLast.AddYears(1) )
$OneYearLater.ToString("yyyy-MM-dd (ddd) hh:mm:ss")
-> 2009-01-31 (Sat) 12:00:00
$string
All members of the .NET String object are supported. See String class at MSDN
string $string.Join(string[] parts, string join) #set ( $s = 'a,b,c,d,e' )
#set ( $parts = $string.Split($s, ',') )
#set ( $s = $string.Join($parts, '-') )
$s
-> a-b-c-d-e
string[] $string.Split(string s, string split) #set ( $s = 'a,b,c,d,e' )
#set ( $parts = $string.Split($s, ',') )
#foreach ( $part in $parts )
  $part |
#end
-> a | b | c | d | e |
string $string.Combine(params object[] parts) #set ( $a = '123' )
$set ( $b = '456' )
#set ( $c = $string.Combine('(', $a, '-', $b, ')') )
$c
-> (123-456)
string $string.GetPart(string s,
                       string split, int index)
$string.GetPart('a,b,c,d,e', ',' , 1)
-> b

$string.GetPart('a,b,c,d,e', ',' , -2)
-> d
Data structures
$hash
A key/value pair structure, like Hashtable. $hash provides a ready to use Hash instance.
Use $hash.Create() to create a new Hash instance.
Hash $hash.Create() $hash.Set("a", 1)
$hash.Set("b", 2)

#set ( $h2 = $hash.Create() )
$h2.Set("x", 3)
$h2.Set("y", 4)
$h2.Set("z", 5)

#foreach ( $key in $hash.Keys )
  $key = $hash.Get( $key ),
#end
-> a = 1, b = 2,

#foreach ( $key in $h2.Keys )
  $key = $h2.Get( $key ),
#end
-> x = 3, y = 4, z = 5,

$hash.Count / $h2.Count
-> 2 / 3

#set ( $sum = $hash.Get('a') + $h2.Get('x') )
$sum
-> 4
int Count 
string[] Keys 
void Remove(object key) 
object Get(object key) 
void Set(object key, object val) 
$list
A list structure, like ArrayList. It implements IEnumerator and IEnumerable.
List $list.Create() #set ( $h1 = $hash.Create() )
#set ( $h2 = $hash.Create() )

$h1.Set("a", 1)
$h1.Set("b", 2)

$h2.Set("x", 3)
$h2.Set("y", 4)

$list.Add($h1)
$list.Add($h2)

$list.Get(0).Get("a")
-> 1

#foreach ( $h in $list )
  #foreach ( $k in $h.Keys )
    $k = $h.Get( $k ),
  #end
#end
-> a = 1, b = 2, x = 3, y = 4,

#set ( $prices = $list.Create() )
$prices.Add(11)
$prices.Add(22)

#set ( $sum = 0 )
#foreach ( $price in $prices )
  #set ( $sum = $sum + $price )
#end
$sum
-> 33

$prices.Add("abc")
$prices.Add("xyz")
$prices.Add($now)
$prices.Add(true)
$prices.Join("-|-")
-> 11-|-22-|-33-|-abc-|-xyz-|-9/28/2008 12:49:27 AM-|-True
int Count 
ArrayList Items 
void Remove(int idx) 
void Set(int idx, object o) 
void Add(object o) 
object Get(int idx) 
string Join(string join) 
IEnumerator and IEnumerable 
External resources
$email
Using the Host SMTP info to send an email
bool Send(string from, string to, string subject, string body) $email.Send("me@here.com", "you@there.com", "hi", "how are you dong?")
$sql
string Check(string s) $sql.Check("foo's bar")
-> foo''s bar
List GetList(string query) #set ( $mods = $sql.GetList( "select m.moduleid, m.moduletitle from modules m, tabs t, tabmodules tm where t.tabid = tm.tabid and m.moduleid = tm.moduleid and t.tabid = $qs.Get('TabID') " ) )
#foreach ( $m in $mods )
  <a href='?mid=$m.Get("ModuleID")'>$m.Get("ModuleTitle")</a><br/>
#end
->
<a href='?mid=11'>my page module 1</a><br/>
<a href='?mid=27'>my page module 2</a><br/>
<a href='?mid=45'>my page module 3</a><br/>
Hash GetHash(string query) #set ( $p = $sql.GetHash( "select * from portals where portalID = $portal.portalID" ) )
$p.Get("PortalID") = $p.Get("PortalName")
-> 0 = default portal
object GetValue(string query) #set ( $count = $sql.GetValue( "select count(*) as c from portals" ) )
$count
-> x, where x is number of portals in your database
List<Hash> Pivot(string IdField, string NameField, string ValueField, string SortField, string Query)
Pivot allows you to transform a id-name-value record set to a column named and sorted record set.
Database:

IDPropertyNamePropertyValue
1NameJohn
1Notejohn blah blah
1SortOrder2
2NameTom
2Notetom notes
2SortOrder1

Template:

#set ( $rows = $sql.Pivot("ID", "PropertyName", "PropertyValue", "SortOrder", "select * from table" ) )
#foreach ( $row in $rows )
  $row.Get('id'). $row.Get('Name') - $row.Get('Notes')
#end

Output:

1. Tom - tom notes
2. John - john blah blah blah
Hash GetIndex(string IndexField, string Query)
GetIndex allows you to index a record set by a given field, and grouping the rows with the same index field value to a sub list. The sub lists, could then be retrieved by the index field values.
Database:

EmployeeIDDepartmentIDName
1111John
2222Tom
3111Amy
4222Zoe

Template:

#set ( $idx = $sql.GetIndex("DepartmentID", "select * from table" ) )
#foreach ( $dept in $idx.Keys )
  dept: $dept
  #set ( $employees = $idx.Get( $dept ).Items )
  #foreach ( $emp in $employees )
    emp: $emp.Get('EmployeeID'). $emp.Get('Name')
  #end
#end

Output:

dept: 111
  emp: 1. John
  emp: 3. Amy
dept: 222
  emp: 2. Tom
  emp: 4. Zoe
$web
Since $web executes on the server side, it can potentially retrieve information from private intranet sites. If you wish to be sure your intranet sites are protected, create a file named Netism.Template.Url.Blacklist.resx and place it under the webroot. A black list of url substring can be defined. One url substring per line, place # for the first character in the line for commenting. The black list file would be denied for public access due to the resx file extension.

For example:
192.168.1.
#localhost
intranet.

$web blocks all url requests that contains the string "192.168.1." or "intranet.". localhost would be allowed, since it's commeNSEd by the # sign.

Using the $web methods, you can easily add news, weather, stock quotes, rss feeds and other web widgets.
string page(string url) #set ( $html = $web.page("http://news.google.com") )
$html.Length
-> 196848

#set ( $start = $html.IndexOf('<title>') + 7 )
#set ( $len = $html.IndexOf('</title>') - $start )
#set ( $title = $html.Substring( $start, $len ) )

$text.HtmlEncode( $title.Trim() )
-> Google News
Rss.RssChannel rss(string url) #set ( $rss = $web.rss("http://rss.cnn.com/rss/cnn_tech.rss") )

<a href="$rss.Link"><b>$rss.Title</b></a>
#foreach ( $item in $rss.Items )
  <a href="$item.Link">$item.Title</a>
#end
->
CNN.com - Technology
news title 1
news title 2
news title 3
news title 4
...

$web.rss() references the RSS.NET library,
see more details at http://www.rssdotnet.com/
$fs
Read/write folders and files. Only folders and files under the running portal are allowed access. All paths must be specified using absolute paths relative to the portal folder. Path must start with "/" and must not contains "..". This prevents directory traversal attack.

For example, if your DNN installation is on c:\dnn and your portalID is 2, then:

/news.txt would be translated to c:\dnn\portals\2\news.txt
/images/icons would be translated to c:\dnn\portals\2\images\icons
string Read(
    string path)
 
FileInfo File(
    string path)
 
FileInfo[] Files(
    string folder)
 
FileInfo[] Files(
    string folder, string pattern)
 
DirectoryInfo Folder(
    string path)
 
DirectoryInfo[] Folders(
    string path)
 
DirectoryInfo[] Folders(
    string path, string pattern)
 
DirectoryInfo[] AllFolders(
    string path)
 
DirectoryInfo[] AllFolders(
    string path, string pattern)
 
DirectoryInfo[] SortFoldersByLastWriteTime(
    DirectoryInfo[] folders,
    bool isDesc)
 
DirectoryInfo[] SortFoldersByLastWriteTime(
    DirectoryInfo[] folders,
    bool isDesc, string pattern)
 
DirectoryInfo[] SortFoldersByCreationTime(
    DirectoryInfo[] folders,
    bool isDesc)
 
DirectoryInfo[] SortFoldersByCreationTime(
    DirectoryInfo[] folders,
    bool isDesc, string pattern)
 
DirectoryInfo[] SortFoldersByFiles(D
    irectoryInfo[] folders,
    bool isDesc)
 
DirectoryInfo[] SortFoldersByFiles(
    DirectoryInfo[] folders,
    bool isDesc, string pattern)
 
DirectoryInfo[] SortFoldersByName(
    DirectoryInfo[] folders,
    bool isDesc)
 
DirectoryInfo[] SortFoldersByName(
    DirectoryInfo[] folders,
    bool isDesc, string pattern)
 
DirectoryInfo[] SortFoldersByFullName(
    DirectoryInfo[] folders,
    bool isDesc)
 
DirectoryInfo[] SortFoldersByFullName(
    DirectoryInfo[] folders,
    bool isDesc, string pattern)
 
void Write(string path, string content) 
void Append(string path, string content) 
void AppendLine(string path, string content) 
bool IsWrite(string path, string content) 
bool IsAppend(string path, string content) 
bool IsAppendLine(string path, string content)