Skip to content

Instantly share code, notes, and snippets.

@mhulse
mhulse / text.csp
Created June 13, 2012 22:50
Caché DTI ContentPublisher: Tested in 7.6, 7.7.2: RG story text methods...
<csp:comment>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++</csp:comment>
<script language="cache" method="storyText" arguments='cmsStory:dt.cms.schema.CMSStory=-1, extractFlag:%String = "none", wordLimit:%String="", charLimit:%String="", sentenceLimit:%String="", paragraphLimit:%String="", ellipsis:%String="TRUE", update:%String=""' returntype="%String" procedureblock="1">
set return = ""
if ($isobject(cmsStory)) {
// Get the text:
@mhulse
mhulse / ad.csp
Created June 13, 2012 22:28
Caché DTI ContentPublisher: Tested in 7.6: Example of COS/CSP count of </p> tags to insert in-story ads...
<csp:object name="gStory" classname="dt.cms.schema.CMSStory" objid="28222340">
<csp:if condition=($isobject(gStory))>
#[ new text set text = ##class(dt.cms.support.Rules).extractStoryElement("Text", gStory, 0) ]#
<csp:if condition=($length(text))>
<h1>With ad:</h1>
@mhulse
mhulse / bloggers.html
Created June 11, 2012 00:17
HTML5: Marking-up a list of bloggers.
<!-- ... content before ... -->
<section>
<hgroup>
<h1>Heading</h1>
<h2>Subheading</h2>
</hgroup>
<figure itemscope itemtype="http://schema.org/Person">
@mhulse
mhulse / section-page.html
Created June 11, 2012 00:03
HTML5: Marking-up a list of "today's" stories for a mock "section front" page.
<!-- ... content before ... -->
<section>
<!-- Section: "Today's stories" -->
<h1>Today's stories</h1>
<section>
@mhulse
mhulse / image.csp
Created June 7, 2012 18:47
Caché DTI ContentPublisher: Tested in 7.6: Example code to fix image paths using ..UnescapeHTML() and ..EscapeURL().
<script language="cache" method="OnPreHTTP" arguments="" returntype="%Boolean">
do %response.SetHeader("Content-Type", "text/plain")
quit 1 // Exit.
</script>
<csp:object name="gStory" classname="dt.cms.schema.CMSStory" objid="28188418">
@mhulse
mhulse / Image.csp
Created June 5, 2012 22:07
Caché DTI ContentPublisher: Tested in 7.6, 7.7.2: RG image methods...
<csp:comment>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++</csp:comment>
<script language="cache" method="imageUri" arguments='field:%String="", cmsStory:dt.cms.schema.CMSStory=-1' returntype="%String" procedureblock="1">
set return = ""
if ($length(field) && $isobject(cmsStory)) {
set cmsPictureId = ##class(dt.cms.support.Rules).extractPicture(field, cmsStory, 0)
@mhulse
mhulse / search.csp
Created May 16, 2012 18:43
Caché DTI ContentPublisher: Tested in 7.6, 7.7.2: DEMO: Sorting search results by CMSStory property (in this case, I'm using publishedToWebDate")...
<csp:comment>
/// Sort ListObjects based on one or more properties.<br>
/// obj: A list object.<br>
/// dir: Direction, 1 ascending, -1 descending.<br>
/// prp: A property name.<br>
/// (c) 2008 J.Kavay<br>
/// Ref: http://groups.google.com/group/intersystems-public-cache/browse_thread/thread/289bc2e02e4875ff
</csp:comment>
<script language="cache" method="multiSortListObj" arguments='obj:%ListOfObjects=-1, dir:%Integer=1, prp...' returntype="%ListOfObjects" procedureblock="1">
@mhulse
mhulse / DateTime.csp
Created April 5, 2012 22:20
Caché DTI ContentPublisher: Tested in 7.6: A Simple CSP method that gets the StartDate timestamp from the dt_cms_schema.CMSStoryPubTracking table.
<csp:comment>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++</csp:comment>
<script language="cache" method="cmsPubTracking" arguments='cmsStory:dt.cms.schema.CMSStory=-1, latest:%Integer=0' returntype="%TimeStamp" procedureblock="1">
set return = ""
; By default, get the oldest entry:
set order = $case(latest, 1:"DESC", :"ASC")
try {
@mhulse
mhulse / buildCommentsSection.csp
Created April 5, 2012 18:42
Caché DTI ContentPublisher: Builds comments for a specific section (code tested on a system using the new "Unified Namespace" setup)...
<!--|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||-->
<csp:comment>
/// buildCommentsSection.csp
/// Builds comments for a specific section
/// 3/21/12
/// Courtesy Trib Steve / Pittsburgh Tribune Review
</csp:comment>
#[ set myBlogDefaultMessage = "There are no recent comments" ]#