Miscellaneous Tags
The miscellaneous tags consist primarily of functions, like <dpLength> which calculates the length of a tag value or string by character, word, sentence or paragraph. Other miscellaneous tags include <dpMath> which allows you to perform mathematical operations, and <dpSpawn> which allows a template to create other pages within your site, most commonly used for server side includes or micro sites, like author archive pages.
<dpArray>
D E F I N I T I O N:
<dpArray> allows you to sort and display values you set in an array using <dpArrayElement>. It is most commonly used to display unique and sorted lists of authors in your database.
<dpArray
name="arrayName"
sort="ascending|descending|asc|desc"
number="all|#"
return="value|count"
>
A T T R I B U T E S:
E X A M P L E S:
<dpArray name="myList" sort="ascending">
myList has <dpArray name="myList" return="count"> values.
<dpLoop var="i" from="1" to="<dpArray name="myList" return="count">">
<dpArray name="myList" number="<dpVar i>" sort="ascending">
</dpLoop>
D E T A I L S:
Defining and Using an <dpArray>
The following will define an array named "myList". It will then load two values into the array. Notice that the values require a key which is used for sorting, and a value which is used when you display the array.
T A G C O D E:
<dpArrayElement name="myList" key="gerken, wil">
Wil Gerken<br>
</dpArrayElement>
<dpArrayElement name="myList" key="forbes, collin">
Collin Forbes<br>
</dpArrayElement>
The following will sort the values in the "myList" array and display them all.
<dpArray name="myList" sort="ascending" number="all">
which will return:
Collin Forbes<br>
Wil Gerken<br>
Give it a try in the tag tester.
E F F E C T:
Creating an Author List
The following produces a two column layout of unique authors sorted alphabetically. To add links to the author archive page, modify the array element to include the desired link. For instance:
<a href="../authors/<dpAuthorID number="<dpVar i>">"><dpAuthor number="<dpVar i>"></a><br>
T A G C O D E:
<dpQuery issue="all" realm="author">
<dpLoop var="i" from="1" to="<dpAuthor return="count">">
<dpArrayElement name="myList" key="<dpAuthor number="<dpVar i>"
format="lastfirst">">
<dpAuthor number="<dpVar i>"><br>
</dpArrayElement>
</dpLoop>
</dpQuery>
<dpComment>
Set middle marker and offset by one if uneven so left side gets extra length.
</dpComment>
<dpVar top="<dpArray name="myList" return="count">">
<dpVar middle="<dpMath <dpVar top>/2>">
<dpIf <dpMath <dpVar top>%<dpVar middle>> != 0>
<dpVar middle="<dpMath <dpVar middle>+1>">
</dpIf>
<dpComment>
Render dual column table
</dpComment>
<table border="1" cellpadding="5" cellspacing="1">
<tr>
<td valign="top">
<ul>
<dpLoop var="i" from="1" to="<dpVar top>">
<li><dpArray name="myList" sort="ascending" number="<dpVar i>">
<dpIf <dpVar i> = <dpVar middle>>
</ul>
</td>
<td valign="top">
<ul>
</dpIf>
</dpLoop>
</ul>
</td>
</tr>
</table>
E F F E C T:
<dpArrayElement>
D E F I N I T I O N:
<dpArrayElement> lets you define elements within an array. It is always used in conjunction with <dpArray>.
<dpArrayElement name="arrayName" key="sort value">
Value
</dpArrayElement>
A T T R I B U T E S:
D E T A I L S:
<dpComment>
D E F I N I T I O N:
<dpComment> provides a method for you to put comments within your template. Unlike HTML comments, these comments will be removed when the template is built.
<dpComment>Comment goes here.</dpComment>
<dpComment>
Comment goes here.
</dpComment>
A T T R I B U T E S:
Not applicable.
E X A M P L E S:
<dpComment>
--------------------------------------------------------------------------
Create a list of all the authors in my database.
--------------------------------------------------------------------------
</dpComment>
<dpQuery issue="all" realm="author" sort="author">
<dpAuthor><br>
</dpQuery>
<dpCurrentIssue>
D E F I N I T I O N:
This tag will return the issue/issueID of the latest issue in your database. It's purpose is primarily to use in a conditional test to see if the issue being built is the current issue or not.
<dpCurrentIssue
default="default text"
style="lower|upper|title|spaced|roman|decimal|identifier|
noHtml|noHtmlStyle|scriptEncode|uriEncode"
link="on|off"
start="#p|#s|#w|#c|begin|end|resume"
stop="#p|#s|#w|#c|begin|end|resume"
length="#p|#s|#w|#c|begin|end"
>
A T T R I B U T E S:
Please refer to the common attributes page for the common attribute descriptions.
E X A M P L E S:
<dpIf <dpIssue> = <dpCurrentIssue>>
{create author archive pages}
</dpIf>
This Week in Film:
<dpQuery issue="<dpCurrentIssue>" section="film">
<dpHeadline link="on"><br>
<dpSummary><p>
</dpQuery>
<dpInclude>
D E F I N I T I O N:
<dpInclude> allows you to pull in (include) a template within a template. This is most commonly used for pulling in a template full of common macros, or design headers and footers.
<dpInclude
template="template name"
>
A T T R I B U T E S:
<dpLength>
D E F I N I T I O N:
<dpLength> returns the length of a string in paragraphs (p), sentences (s), words (w), or characters (c).
<dpLength unit="p|s|w|c">string or tag(s) to evaluate</dpLength>
A T T R I B U T E S:
Not applicable.
E X A M P L E S:
<dpLength unit="w">How many words?</dpLength> would return 3
<dpLength unit="w">How many characters?</dpLength> would return 18
A more common usage would be:
<dpVar totalParagraphs="<dpLength unit="p"><dpStory></dpLength>">
You now have a variable that holds the number of total paragraphs this story has. This can be used for layout purposes, statistical information like word count, a variable to determine if you should split this story into multiple pages, etc.
<dpMath>
D E F I N I T I O N:
<dpMath> lets you perform mathematical calculations within the tag and will return the result.
<dpMath calculation goes here>
O P E R A T O R S:
+, -, *, /, ( )
E X A M P L E S:
<dpMath 4+4> would return 8
<dpMath <dpLength unit="p"><dpStory></dpLength> - 4>
would return the length of the story in paragraphs subtracting 4.
<dpSpawn>
D E F I N I T I O N:
Spawn provides a method for a template to build additional files. This is most commonly used to generate server side includes, or to create and/or update mini sites.
This syntax it used to define a template inline. Mostly common for creating include files.
<dpSpawn path="relative path" file="file name">
template defined here
</dpSpawn>
This syntax references an external template you've defined in the Template Manager. This is a common method for mini sites.
<dpSpawn path="relative path" file="file name" template="template name">
A T T R I B U T E S:
E X A M P L E S:
The following code will build author archives for all of the authors in your database. It uses a template defined in the Template Manager called "author archives".
<dpQuery issue="all" realm="author">
<dpSpawn path="/archives/authors/" file="<dpAuthorID>.html" template="author archives">
</dpQuery>
| Home: Support: Reference Guide: Miscellaneous Tags | Questions? Comments? Please write support@desert.net. |