Skip to content

Instantly share code, notes, and snippets.

@scopevale
Forked from cfalzone/TheTemplate
Created June 29, 2016 15:35
Show Gist options
  • Save scopevale/3bbc0bbc837b55724a1d7c34552d7b2a to your computer and use it in GitHub Desktop.
Save scopevale/3bbc0bbc837b55724a1d7c34552d7b2a to your computer and use it in GitHub Desktop.
dotcms template code to inspect the content that is on the page and and inject something into the context for other content to use it
#set($THEFLICKR = "")
<div> <h2>What's I got?</h2>
<ul>
#foreach($key in $context.getKeys())
#if($key.startsWith("contentletList"))
#set($cid = $key.replaceAll("contentList", ""))
<li>Container id = $cid - Contents:
<ul>
#foreach($conid in $context.get($key))
<li>$conid
#set($con = $dotcontent.find($conid))
#if($UtilMethods.isSet($con.get("account")))
#set($THEFLICKR = $con.get("account"))
- Flickr id is $THEFLICKR
#end
</li>
#end
</ul>
</li>
#end
#end
</ul>
</div>
<div> <h2>Container 1</h2>
#parseContainer('0b20ec9a-9401-4b1c-84cc-65ed12a4861e')
## This is autogenerated code that cannot be changed
## Container: Test 1
</div>
<div> <h2>Container 2</h2>
#parseContainer('d92e1ef3-e66f-4199-950d-4aaa62436000')
## This is autogenerated code that cannot be changed
## Container: Test 2
</div>​
<p>This is cool code and the flicker id is $THEFLICKR</p>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment