Using Chunks to establish default values

Sample Chunk Call

Shown below: [[$youtube?videoID=`OpRD_5gCtkI`]]
Override colors: [[$youtube?videoID=`OpRD_5gCtkI`&color1=`0x2b405b`&color2=`0x6b8ab6`]]
Override size: [[$youtube?videoID=`OpRD_5gCtkI`&width=`720`&height=`396`]]

Chunk Code

<object width="[[+width:default=`560`]]" height="[[+height:default=`315`]]">
    <param name="movie" value="[[+videoID]]
    <param name="allowFullScreen" value="true"></param>
    <param name="allowscriptaccess" value="always"></param>
    <embed src="[[+videoID]]&hl=en_US&rel=0&modestbranding=1&color1=[[+color1:default=`0x00ff00`]]&color2=[[+color2:default=`0x007519`]]&hd=[[+allowHiDef:default=`1`]]"

<iframe width="[[+width:default=`560`]]" height="[[+height:default=`315`]]" src="[[+videoID]]?modestbranding=1" frameborder="0" allowfullscreen></iframe>

Sample Chunk Output


By matching the inbound variables (i.e. videoID) with matching placeholders (i.e. ), Youtube videos can be placed in a site with the following benefits:
  • » Very small database footprint
  • » Small amount of embed code to work around
  • » Consistent presentation throughout site
  • » The chunk itself can be cached

These benefits can be experienced when ever a MODX Revolution Chunk is used to represent content which only slightly changes, based on some variable component.

Any of the properties in the above Chunk could have been switched out to variables: width, height, color, etc.

Also, take note on how a MODX Revolution filter ":default" was used to establish a baseline set of values, which could have easily been overridden in the Chunk Call.

Some users may prefer setting up property sets instead, which can also be overridden at run time via the Chunk Call.

Even though YouTube, is pushing its embed code via html iframes now, I prefer the ability to theme the presentation inline. When they ever get around to adding this capability to their new embed code, I will gladly update this page with the new code.