 |
Common Attributes
The common attributes are attributes that are common to most Dispatch tags. These attributes are:
default,
style,
link,
start,
stop and
length
- default = "default text"
-
The "default" attribute allows you to set a default value for a Dispatch tag. You can use the default attribute to define what should happen if a tag has no value, such as a story without an author
or headline.
Examples:
If a story has an author, the <dpAuthor> tag will display it as usual. You can also use the default attribute for the scenario of a story without an author.
|
<dpAuthor default="Staff Writer">
|
Staff Writer
|
|
<dpAuthor default="Anonymous">
|
Anonymous
|
An example of the default attribute used within the <dpHeadline> tag. Notice the use of nesting a tag within a tag.
|
<dpHeadline default="<dpColumn>">
|
Cinema Review
|
In the following example, if the story has a summary, it is displayed as usual. If the story doesn't have a summary the default value is used. In this case the default value is the first two sentences of the story, followed by an ellipses.
|
<dpSummary default="<dpStory length="2s">...">
|
What's left to be said about Woody Allen? Or maybe the
question is, "What does Woody have left to say?"...
|
- style = "lower|upper|title|spaced|roman|decimal|noHtml|noHtmlStyle|identifier|scriptEncode|uriEncode"
-
The style attribute allows you to change the formatting style of a tag. You can change the style to lower case, upper case, title case, spaced, roman decimal, decimal, remove or encode HTML, or any combination of styles.
style="lower" - converts to "lower case".
style="upper" - converts to "UPPER CASE".
style="title" - converts to "Title Case". Note: use title case with caution. Due to the complexities of the English language, it may not always be 100% accurate.
style="spaced" - adds a space between each character. "s p a c e d"
style="roman" - converts to roman numeral: IX
style="decimal" - converts to decimal: 9
style="noHtml" - removes all HTML.
style="noHtmlStyle" - removes all HTML except paragraphs <p> and breaks <br>.
style="identifier" - converts to lower case letters with no spaces. This is primarily used for creating file names.
style="scriptEncode" - converts quotes, commas, and apostrophes to their
numeric ASCII values. Primarily used within JavaScript or other scripting
languages.
style="uriEncode" - encodes the text so it can be passed through a URL. This is often used
for passing a query string on to an external search engine or commerce site.
style="chef", style="cockney", style="fudd", style="jive", style="kraut", style="newspeak", style="valspeak" - dialect translator Easter eggs. Read more about these here
Examples:
|
<dpHeadline>
|
Censored stories, 1998
|
|
<dpHeadline style="lower">
|
censored stories, 1998
|
|
<dpHeadline style="upper">
|
CENSORED STORIES, 1998
|
|
<dpHeadline style="title">
|
Censored Stories, 1998
|
|
<dpHeadline style="spaced">
|
C e n s o r e d s t o r i e s , 1 9 9 8
|
|
<dpHeadline style="roman">
|
Censored stories, MCMXCVIII
|
|
<dpHeadline style="decimal">
|
Censored stories, 1998
|
|
<dpHeadline style="spaced" style="upper">
|
C E N S O R E D S T O R I E S , 1 9 9 8
|
|
<dpHeadline style="uriEncode">
|
Censored+stories,+1998
|
- link = "on|off|email|homepage"
- The link attribute provides shorthand for creating a link around a tag, and is most commonly used within queries.
link="on" - creates a link to the story associated with the tag.
link="off" - no link is created. This is the default value for most tags.
link="email" - creates an email link. Note: this is only available on the <dpAuthor> and <dpImageArtist> tag.
link="homepage" - creates a link to a homepage. Note: this is only available on the <dpAuthor> and <dpImageArtist> tag.
Examples:
- start = "#p|#s|#w|#c|begin|end|resume"
- stop = "#p|#s|#w|#c|begin|end|resume"
- length = "#p|#s|#w|#c|begin|end"
- Start, stop, and length manipulate the text returned by a tag,
and are best described as a set of attributes.
The text that is returned by a tag is known as a "string". By default,
the entire string is returned, and these attributes are not
used. However, if you would like to
return only a portion of the string, or manipulate the string
in any way, you will need to use some or all of these attributes.
start - where to begin within the string
stop - where to end within the string
length - the length to return, most commonly used by itself or
in conjunction with start.
#p - number of paragraphs. 1p = one paragraph, 2p = two paragraphs, etc.
#s - number of sentences. 1s = one sentence, 4s = four sentences, etc.
#w - number of words. 1w = one word, 5w = five words, etc.
#c - number of characters. 1c = one character, 10c = ten characters, etc.
begin - the beginning of the string
end - the end of the string
resume - continue from where you just left off. "Resume" will be equal to
"begin" on the first call, and then equal to where you ended for the next call.
Examples:
Note: Spaces are counted as characters, but consecutive spaces are counted as only one character.
|
<dpHeadline>
|
All Fired Up
|
|
<dpHeadline length="1w">
|
All
|
|
<dpHeadline length="2w">
|
All Fired
|
|
<dpHeadline length="3w">
|
All Fired Up
|
|
<dpHeadline length="3c">
|
All
|
|
<dpHeadline length="5c">
|
All F
|
Note: "Start" always begins after what you specify as the starting position,
as in these examples below:
|
<dpHeadline start="begin">
|
All Fired Up
|
|
<dpHeadline start="1w">
|
Fired Up
|
|
<dpHeadline start="2w">
|
Up
|
|
<dpHeadline start="2c">
|
l Fired Up
|
|
<dpHeadline start="8c">
|
d Up
|
Note: "Stop" specifies what position to stop at, unlike "length" which specifies how much to return.
|
<dpHeadline start="4c" stop="5c">
|
F
|
|
<dpHeadline start="5c" stop="7c">
|
ir
|
|
<dpHeadline start="2w" stop="3w">
|
Up
|
|
 |