Created
September 18, 2014 20:29
-
-
Save mhulse/43f68c1773d6a0a04dce to your computer and use it in GitHub Desktop.
Caché 2009.1 - NEWSCYCLE Solutions: DTI Lighting 7.7.x: Get story link CSP methods.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script language="cache" method="uri" arguments="section:dt.cms.schema.Section=-1, story:dt.cms.schema.CMSStory=-1, layout:dt.cms.schema.LayoutFull=-1" returntype="%String" procedureblock="1"> | |
/// Returns a story link; InCopy field "WebLink" trumps story link. | |
/// All parameters required. | |
/// Example call: ##class(csp.rg.assets.methods.story).uri(gSection, gStory, gFullLayout) | |
set return = "" | |
set:( ' $isobject(story)) story = ##class(dt.cms.schema.CMSStory).%OpenId(story) | |
if ($isobject(story)) { | |
set return = $zstrip(##class(dt.cms.support.Rules).extractStoryElement("WebLink", story, 0, "textonly"), "<>W") // Extract WebLink (if it exists) and trim whitespace. | |
if ( ' $length(return)) { | |
set return = ..getLink(section, story, layout) | |
} | |
} | |
quit return | |
</script> | |
<script language="cache" method="getLink" arguments='section:dt.cms.schema.Section=-1, story:dt.cms.schema.CMSStory=-1, layout:dt.cms.schema.LayoutFull=-1' returntype="%String" procedureblock="1"> | |
/// Does not take into account InCopy field "WebLink". | |
/// Use ##class(csp.rg.assets.methods.story).uri() instead. | |
; Initialize return string: | |
set return = "" | |
; dt.cms.schema.Section? | |
set:( ' $isobject(section)) section = ##class(dt.cms.schema.Section).%OpenId(section) | |
; dt.cms.schema.CMSStory? | |
set:( ' $isobject(story)) story = ##class(dt.cms.schema.CMSStory).%OpenId(story) | |
; dt.cms.schema.LayoutFull? | |
set:( ' $isobject(layout)) layout = ##class(dt.cms.schema.LayoutFull).%OpenId(layout) | |
set:($isobject(story) && $isobject(section) && $isobject(layout)) return = story.getLink(section, layout) | |
quit return | |
</script> | |
<csp:comment> | |
#[ new qs set qs = $get(%request.Data("cid", 1)) ]# | |
<csp:if condition='qs \ 1'> | |
<!-- | |
190 = section ID (Staging) | |
110 = second ID in story url: 32172565-110 | |
--> | |
#(..uri(190, qs, 110))# <!-- Confirm that things match. --> | |
<csp:object name="gSection" classname="dt.cms.schema.Section" objid="190"> | |
<csp:if condition=($isobject(gSection))> | |
<p>Section: #(gSection.getLabel())#, #(gSection.%Id())# | #(..uri(gSection, qs, 110))#</p> <!-- Confirm that things match. --> | |
<csp:object name="gStory" classname="dt.cms.schema.CMSStory" objid="#(qs)#"> | |
<csp:if condition=($isobject(gStory))> | |
<p>Story: #(gStory.getName())#, #(gStory.%Id())# | #(..uri(gSection, gStory, 110))#</p> <!-- Confirm that things match. --> | |
<csp:object name="gFullLayout" classname="dt.cms.schema.LayoutFull" objid="110"> | |
<csp:if condition=($isobject(gFullLayout))> | |
<p>FullLayout: #(gFullLayout.name)#, #(gFullLayout.%Id())# | #(..uri(gSection, gStory, gFullLayout))#</p> <!-- Confirm that things match. --> | |
<!--quit ##class(dt.cms.support.Rules).getStoryLink(##this,sectionObject,fullLayout).getLink()--> | |
<a href="#(gStory.getLink(gSection, gFullLayout))#" rel="_blank">#(gStory.getLink(gSection, gFullLayout))#</a> | |
</csp:if> | |
</csp:if> | |
</csp:if> | |
</csp:if> | |
#[ k qs ]# | |
</csp:comment> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment