Skip to content

Instantly share code, notes, and snippets.

@mhulse
Created June 13, 2012 23:00
Show Gist options
  • Save mhulse/2927050 to your computer and use it in GitHub Desktop.
Save mhulse/2927050 to your computer and use it in GitHub Desktop.
Caché DTI ContentPublisher: Tested in 7.6, 7.7.2: RG story headline methods...
<csp:comment>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++</csp:comment>
<csp:comment>
Get story headline.
Call: ##class(csp.web.assets.methods.story).headline()
Dependencies: 1) ..dboStoryStatus(), 2) ##class(dt.cms.support.Rules).extractStoryElement
</csp:comment>
<script language="cache" method="headline" arguments='cmsStory:dt.cms.schema.CMSStory=-1, update:%String=""' returntype="%String" procedureblock="1">
/// This method will return a headline based on The Register-Guard order of precedence:
/// 1) "WebHeadline"
/// 2) "Headline"
/// 3) "Deck"
/// 4) "QuickRead"
/// 5) "Header"
/// 6) "StorySig"
/// 7) "Kicker"
/// 8) "FurnitureText"
/// 9) Story slug (Default return value)
/// Arguments:
/// @param01: A valid CMSStory object.
/// @param02: If set to "true", only the WebUpdateHeadline will be returned.
set return = ""
if ($isobject(cmsStory)) {
; If "update" = "true" OR if the story status is NOT "ready", "web" or "output", show the WebUpdateHeadline:
if (($zconvert(update, "U") = "TRUE") || (($zconvert(update, "U") '= "FALSE") & (..dboStoryStatus(cmsStory) = 0))) {
set return = ##class(dt.cms.support.Rules).extractStoryElement("WebUpdateHeadline", cmsStory, 0, "textonly")
} else {
; Trying to avoid spaghetti code here... Almost to a fault. :(
set return = ##class(dt.cms.support.Rules).extractStoryElement("WebHeadline", cmsStory, 0, "textonly")
if ('$length(return)) {
set return = ##class(dt.cms.support.Rules).extractStoryElement("Headline", cmsStory, 0, "textonly")
if ('$length(return)) {
set return = ##class(dt.cms.support.Rules).extractStoryElement("Deck", cmsStory, 0, "textonly")
if ('$length(return)) {
set return = ##class(dt.cms.support.Rules).extractStoryElement("QuickRead", cmsStory, 0, "textonly")
if ('$length(return)) {
set return = $zconvert(##class(dt.cms.support.Rules).extractStoryElement("Header", cmsStory, 0, "textonly"), "U")
if ('$length(return)) {
set return = $zconvert(##class(dt.cms.support.Rules).extractStoryElement("StorySig", cmsStory, 0, "textonly"), "U")
if ('$length(return)) {
set return = $zconvert(##class(dt.cms.support.Rules).extractStoryElement("Kicker", cmsStory, 0, "textonly"), "U")
if ('$length(return)) {
set return = ##class(dt.cms.support.Rules).extractStoryElement("StoryLabel", cmsStory, 0, "textonly")
if ('$length(return)) {
set return = $zconvert(##class(dt.cms.support.Rules).extractStoryElement("FurnitureText", cmsStory, 0, "textonly"), "U")
if ('$length(return)) {
set return = cmsStory.story.storyName // Return slug if all else fails.
}
}
}
}
}
}
}
}
}
}
}
quit return
</script>
<csp:comment>
<csp:object name="gStory" classname="dt.cms.schema.CMSStory" objid="25802356">
#(..headline(gStory))#
</csp:comment>
<csp:comment>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++</csp:comment>
<script language="cache" method="dboStoryStatus" arguments="cmsStory:dt.cms.schema.CMSStory=-1" returntype="%Integer" procedureblock="1">
/// ##class(csp.web.assets.methods.story).dboStoryStatus()
/// About: Return 1 if the given story has a status of "web", "ready", or "output".
/// Example call:
set return = 0
/*
**
** SQL to check current status list:
** SELECT statusName, statusId FROM dbo.status ORDER BY statusId ASC
**
** "-" = 0
** "Notes" = 1
** "Raw" = 2
** "In Progress" = 3
** "Story Completed = 4
** "First Edit" = 5
** "Rimmed" = 9
** "Ready" = 10
** "Output" = 1018
** "Web" = 1019
** "Archive" = 118709
** "Hold" = 632458
**
*/
if ($isobject(cmsStory) && $isobject(cmsStory.story)) {
set statusId = 0
; DBO.story Status Id:
set statusId = cmsStory.story.statusId
; Check if statusId is "ready", "web", or "output":
set:((statusId = 10) || (statusId = 1018) || (statusId = 1019)) return = 1
}
quit return
</script>
<csp:comment>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++</csp:comment>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment