Pages

Wednesday, November 17, 2010

Delivery Server: Basic Syntax


Delivery Server (DS) code is executed within the DS engine, and the plain HTML response is sent to the clients browser.

Your code can either be written directly within the Reddot templates pages them self or within an xml page managed within the Delivery Server.


All code managed with the DS engine must be encased by xml tags, such as <dynaments> code ... </dynaments>. These tags can literally be anything you like, but it is recommended to use the standard dynaments tag.

The Basic Idea

<dynaments>
  <rde-dm:attribute mode="write" 
                attribute="request:tmpvar" 
                value="Hello World!" 
                tag="notag" />
  <rde-dm:attribute mode="read" 
                attribute="request:tmpvar" 
                tag="notag" />
</dynaments>


Mode
Read: displays variable/content to the web page
Write: creates a variable and assigns value to attribute

Attribute
source : variable name

     Source
  • Request local variable used during a specific request
  • Users -  user define in memory cache or user database attributes
  • Cookie
  • Context - used within for-each loops
  • Content - Global variables
  • Groups
  • Sessions
  • System
  • Response - Over loading default header fields.
  • many more

     Variable
     A variable name - be careful and avoid key name. (like password, username, fullname etc)


Enhance the Idea

If Logic
<rde-dm:attribute mode="condition">
    <rde-dm:constraint>
        (user:profile.location EQ 'Calgary' OR user:profile.location EQ 'Alberta')
    </rde-dm:constraint>
    <rde-dm:if>
        You live in Alberta
    </rde-dm:if>
    <rde-dm:else>
        You live outside Alberta
    </rde-dm:else>
</rde-dm:attribute>

For Each
<rde-dm:attribute mode="for-each" attribute="user:profile.location" alias="location" tag="Locations">
    <rde-dm:attribute mode="read" attribute="context:location" />
</rde-dm:attribute>

Output
<Locations>
 <location>Calgary</location>
 <location>Alberta</location>
</Locations> 

Flush Cache
<rde-dm:attribute mode="flush" type="user" />

Very simple command, huge ramification.  If you happen to write content to the users attributes (such as adding a new location to the user list) then you must flush the cache to active the write.  You should avoid not specifying a type.  In this case, the entire cache is flushed - which could have a HUGE impact on performance.

No comments:

Post a Comment