Skip to content

Instantly share code, notes, and snippets.

@mhulse
Created September 18, 2014 19:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mhulse/c493894e109a210f6ef4 to your computer and use it in GitHub Desktop.
Save mhulse/c493894e109a210f6ef4 to your computer and use it in GitHub Desktop.
Caché 2009.1 - NEWSCYCLE Solutions: DTI Lighting 7.7.x: Get The Register-Guard byline CSP method.
<script language="cache" method="byline" arguments="cmsStory:dt.cms.schema.CMSStory=-1, org:%Boolean=0" returntype="%String" procedureblock="1">
/*
<dti:story:element:exist field="WebByline1">
<p class="Bylines-Byline1"><dti:story:element field="WebByline1" extract="textonly" /></p>
<dti:story:element:exist field="WebByline2">
<p class="Bylines-Byline2"><dti:story:element field="WebByline2" extract="textonly" /></p>
</dti:story:element:exist>
<dti:else>
<dti:story:element:exist field="Byline">
<dti:story:element field="Byline" />
<dti:else>
<csp:comment> 250, 1017 and 15103440 are "City/Region Columnist", "Sports Columnist" and "Sports Columnist FB", repsectively. - JH </csp:comment>
<csp:if condition='$case(gStory.getStory().subCategoryId, "250":1, "1017":1, "15103440":1, :0)'>
<dti:story:element:exist field="Mugline">
<p class="Bylines-Byline1">By <dti:story:element field="Mugline" extract="textonly" /></p>
<p class="Bylines-Byline2">Register-Guard columnist</p>
</dti:story:element:exist>
</csp:if>
</dti:story:element:exist>
</dti:story:element:exist>
*/
#define bystrip(%str) $replace(%str, "BY ", "", 1, -1, 1)
set return = ""
if ($isobject(cmsStory)) {
if (org) {
; "Web" byline organization:
set return = ##class(dt.cms.support.Rules).extractStoryElement("WebByline2", cmsStory, 0, "textonly")
} else {
; "Web" byline name:
set return = $$$bystrip(##class(dt.cms.support.Rules).extractStoryElement("WebByline1", cmsStory, 0, "textonly"))
}
if ('$length(return)) {
; "Print" byline:
set return = ##class(dt.cms.support.Rules).extractStoryElement("Byline", cmsStory, 0, "textonly")
if ($length(return)) {
if (org) {
; "Print" byline organization:
set return = $zstrip($piece(return, $char(10), 2), "<>W")
} else {
; "Print" byline name:
set return = $zstrip($$$bystrip($piece(return, $char(10))), "<>W")
}
} else {
; Columnist?
if (..iscolumnist(cmsStory)) {
; "Print" mugline:
set return = ##class(dt.cms.support.Rules).extractStoryElement("Mugline", cmsStory, 0, "textonly")
; "Print" mugline organization:
set:($length(return) && org) return = "Register-Guard columnist"
}
}
}
}
quit return
</script>
<csp:comment>
<csp:object name="gStory" classname="dt.cms.schema.CMSStory" objid="26037846">
<dti:story:element field="Byline" extract="textonly" />
<hr>
<p class="Bylines-Byline1">By #(..byline(gStory))#</p>
<p class="Bylines-Byline2">#(..byline(gStory, 1))#</p>
</csp:comment>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment