The term tpXSLT covers thePort's XSLT based templating system and its associated objects and methods.
Below you will find the following:
- Basic information about the basic building blocks of a tpXSLT page.
- Links to details pages for each object and its associated methods.
- Some useful tools in creating, editing and debugging tpXSLT pages.
Below you will see the basic structure of a tpXLST page. This is only an example and will differ in many cases. However, it represents a basic idea of the best way to structure tpXSLT page.
The very first line of the page is the xml declaration:
<?xml version="1.0" encoding="utf-8"?>
The next section opens the XSL stylesheet and the objects used on the page (see below) are instantiated.
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:iUser="urn:ThePort.BusinessObj.iUser"
xmlns:iPartner="urn:ThePort.BusinessObj.iPartner"
xmlns:iPageInformation="urn:ThePortBusiness.XSLProcessing.IXSLPageInformation"
xmlns:iSMProcessor="urn:ThePortBusiness.XSLProcessing.ProcessServerModule"
xmlns:iDiscussion="urn:ThePortBusiness.IXSLDiscussion"
exclude-result-prefixes="iUser iPartner iPageInformation iSMProcessor iDiscussion">
The following objects are available to you (clicking on each object will take you to the object's details page):
Next, the XSL output format is declared:
<xsl:output method="html" indent="yes"/>
Then any includes of other XSL stylesheets are declared:
<xsl:include href="/someTemplateIncludeFile.xslt"/>
Include iJSHandler to take advantage of query string tools and several useful xsl functions like string replacement, date/time manipulation, and paging:
<xsl:include href="/iJSHandler.xslt"/>
To view all available xsl functions available in iJSHandler,
click here.
Variables that are global to the page are instantiated (many are through function calls to objects that were instantiated at the top of the page):
<xsl:variable name="sModuleID" select="iPageInformation:GetParameterValue('sModuleID')"/>
<xsl:variable name="oPartner" select="iPartner:IXSLGetBase()"/>
<xsl:variable name="sGlobalByTerm" select="iPartner:IXSLGetLocalization('GLOBAL_BY_LABEL')"/>
XSL templates come next. Unlike most named templates, the template match="go" displays automatically by default - all other named templates must be explicitly called. Multiple named templates can exist in one XSLT stylesheet, but only one match="go" template can exist in the file.
<xsl:template match="go">
In order to take advantage of the useful query string tools at the bottom of this page, this line must be included:
<xsl:call-template name="EmitJSHandlers"/>
Finally, markup is added:
<div class="ModuleWrapper">
<div class="ModuleTitle">Some Title</div>
<div class="ModuleContent">
Templates can be called here. These can be templates that are declared in the same file (like the one below)...
<xsl:call-template name="ALocalTemplate"></xsl:call-template>
... or are included from another file (see include declaration at top of page):
<xsl:call-template name="someIncludedTemplate"></xsl:call-template>
</div>
</div>
</xsl:template>
<xsl:template name="ALocalTemplate">
Hello World!
</xsl:template>
</xsl:stylesheet>
NOTE: In order to take advantage of these helpful tools, this line must be included:
<xsl:call-template name="EmitJSHandlers"/>
Show XML
The xml of an object can be viewed by passing the object into the xslt below (replacing $oInstantiatedObject with your object). A button will appear
on the page that will display the xml of that object when clicked.
<xsl:value-of select="iPageInformation:ShowXML($oInstantiatedObject,'some button name')" disable-output-escaping="yes"/>
Query string tools
By appending one of the following query strings after the URL in your browser, a variety of useful tools are available. For example pasting
http://www.yourcommunity.com/discussions?tp_nc=1 into a browser will flush the server cache for the http://www.yourcommunity.com/discussions page.
Flushing the server cache for a page:
Appending tp_nc=1 flushes the server cache for that page (it recompiles the business objects). Useful to reveal changes you've made that have not
appeared yet due to the old verion being cached on the server.
Force an XLST to recompile/reload:
Appending tp_nc=2 will cause all of the XSLTs that make up a page to recompile/reload. Use tp_nc=2 sparingly since it'll be very slow.
Open a module in its own window:
Appending tp_pop=1 generates a button (on most modules on a page) that will open the module in a new window. Useful for testing an individual piece
of a page rather than having to refresh an entire page each time you make changes.
Generate code to call a module:
Appending the tp_script variable will pop open a window that displays XLST you can use to call that module. Often used to build widgets. The script
can be generated to call the module in one of three ways: tp_script=1 (json), tp_script=2 (dictionary), tp_script=3 (xslt)
Display dictionary values:
Appending tp_dict=1 shows dictionary(s) data values that were passed in the building of the page.
Display timing/profiling information:
Appending tp_stats=1 generates timing/profiling information (best used in IE)
Display file names of xslt modules:
Appending tp_parts=1 shows the file names of many modules on a page (does not show all). Sometimes useful to find out where a particular page element
is coming from.
Display object information:
Appending tp_debug=1 is best used in IE. Each module on a page gets a button that will pop open a new window display all the objects used to build that module along with the xml.
Display drag and drop page configuration xml:
Appending tp_showlayoutxml=1 to a drap and drop page url reveals a button that displays xml defining the specific widgets, spatial layout and settings of the page (at the time the button was clicked). Adding the xml to a community creation configuration file will generate an identical drag and drop page (containing the same widgets, placement and settings) in communities created using that file. Note: this feature will be available after November, 2011.