Last active
December 22, 2015 11:48
-
-
Save mhulse/6468035 to your computer and use it in GitHub Desktop.
Test page for <dti:area:include /> and <dti:story:topnslots ... >...</dti:story:topnslots>.
This file contains hidden or 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" runat="server"> | |
new demo | |
/* | |
**-------------------------------------------------------------------------- | |
** | |
** Demo settings: | |
** | |
**-------------------------------------------------------------------------- | |
*/ | |
/* | |
**---------------------------------- | |
** Enter Publication name: | |
**---------------------------------- | |
*/ | |
set demo("publication") = "rg" | |
/* | |
**---------------------------------- | |
** Enter Section name: | |
**---------------------------------- | |
*/ | |
set demo("section") = "sports" | |
/* | |
**---------------------------------- | |
** Area name(s): | |
**---------------------------------- | |
*/ | |
set demo("area") = "Top Stories" | |
/* | |
**---------------------------------- | |
** Slots to "include": | |
**---------------------------------- | |
*/ | |
set demo("include") = "Top Story 2" // Comma delimited. | |
/* | |
**---------------------------------- | |
** Slots to "exclude": | |
**---------------------------------- | |
*/ | |
set demo("exclude") = "" // Comma delimited. | |
/* | |
**---------------------------------- | |
** Number of items to return: | |
**---------------------------------- | |
*/ | |
set demo("items") = "1" | |
</script> | |
#[ new pid set pid = ##class(dt.cms.support.Utilities).getPublicationID(demo("publication")) ]# | |
<csp:object name="gPublication" classname="dt.cms.schema.Publication" objid="#(pid)#"> | |
<csp:if condition=($isobject(gPublication))> | |
<h1>Publication: #(gPublication.getLabel())#</h1> | |
#[ new sid set sid = ##class(dt.cms.support.Utilities).getSectionID(gPublication, demo("section")) ]# | |
<csp:object name="gSection" classname="dt.cms.schema.Section" objid="#(sid)#"> | |
<csp:if condition=($isobject(gSection))> | |
<section> | |
<h1>Section: #(gSection.getLabel())#</h1> | |
<hr> | |
<script language="cache" runat="server"> | |
/* | |
**-------------------------------------------------------------------------- | |
** | |
** These could be "config" variables found in a global config01.csp file. | |
** Putting here for demo's sake. | |
** On an actual template, gPublication/gSection would be already available. | |
** | |
**-------------------------------------------------------------------------- | |
*/ | |
new g | |
; Current page: | |
set g("page") = ##class(dt.cms.support.Utilities).getCurrentPage(gSection) // dt.cms.schema.Page | |
; Current Page Layout: | |
set g("pagelayout") = g("page").pageLayoutID // dt.cms.schema.PageLayout | |
; Current Grid: | |
set g("grid") = ##class(dt.cms.support.Utilities).getCurrentGrid(gSection) // dt.cms.schema.Grid | |
// Note: We can't depend on gGrid being available in all contexts (it's missing from the story pages). | |
// Thus the reason why it's not a bad idea put the above variables in a global config file. | |
// Addtionally, the above variables reference the "current" values. | |
</script> | |
<h2>Include Area: #(demo("area"))#</h2> | |
<dti:area:include name="#(demo("area"))#" slotinclude="#(demo("include"))#" slotexclude="#(demo("exclude")#" pagename="index.csp" /> | |
<h2>Topnslots tag/RULE:</h2> | |
<ol> | |
<csp:comment> Apparently, "items" (attribute below) does not allow for runtime expressions. </csp:comment> | |
<dti:story:topnslots publication="#(gPublication.getName())#" section="#(gSection.getName())#" pagelayoutname="#(g("pagelayout").name)#" grid="#(g("grid").name)#" area="#(demo("area"))#" items="1"> | |
<dti:story:use storyobj="#(value)#"> | |
<li> | |
<ul> | |
<li>Story ID: #(gStory.%Id())#</li> | |
<li>Story name: #(gStory.getName())#</li> | |
<li>Other: ...</li> | |
</ul> | |
</li> | |
</dti:story:use> | |
</dti:story:topnslots> | |
</ol> | |
<h2>Topnslots COS API call:</h2> | |
#[ new slotted set slotted = ##class(dt.cms.support.TopSlotStories).getTopStories(gPublication.getName(), gSection.getName(), g("pagelayout").name, g("grid").name, demo("area"), demo("items")) ]# | |
<ol> | |
<csp:loop counter="x" from="1" to="#(slotted.Count())#"> | |
<dti:story:use storyobj="#(slotted.GetAt(x))#"> | |
<li> | |
<ul> | |
<li>Story ID: #(gStory.%Id())#</li> | |
<li>Story name: #(gStory.getName())#</li> | |
<li>Other: ...</li> | |
</ul> | |
</li> | |
</dti:story:use> | |
</csp:loop> | |
</ol> | |
#[ kill slotted, g ]# | |
</section> | |
</csp:if> | |
#[ kill sid ]# | |
</section> | |
</csp:if> | |
#[ kill demo, pid ]# | |
<hr> | |
<section> | |
<h1>Debug:</h1> | |
<script language="cache" runat="server"> | |
; Debug: | |
write !, "<pre>" | |
try { | |
set currIO = ##class(%SYS.NLS.Device).SetIO("HTML") | |
zwrite | |
} | |
catch { | |
write "ERROR: ", $ZERROR | |
} | |
if $get(currIO) '= "" { | |
do ##class(%SYS.NLS.Device).SetIO(currIO) | |
} | |
write "</pre>" | |
</script> | |
</section> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment