block chooser in data definition vs outputs
We have a page type that only has a block chooser in the data definition (see attached screen shot).
I had the default region set to "content-center" block and the following format applied without any luck. I changed the default region to the same block that was chosen in the data definition and it worked fine. How would I need to edit my format to pull from the block that's been chosen in the data definition of the page, rather than having to set the block in the output?
#set ($data = $_XPathTool.selectSingleNode($contentRoot,"/system-data-structure"))
#set ($title = $data.getChild("title"))
#set ($image=$data.getChild("image").getChild("link").value)
#set ($topContent=$data.getChild("topContent"))
#set ($bottomContent=$data.getChild("bottomContent"))
<div class="top-Horizontal-container cf">
<!--left side container-->
<div class="Horizontal-left">
<h1>$_EscapeTool.xml($title.value)</h1>
<p>$_SerializerTool.serialize($topContent, true)</p>
</div>
<!--left side container end-->
<!--right side container-->
<div class="Horizontal-right">
<img class ="horizontal-image" src="${image}"/><br />
<div class="share-print-link">
<a href="#" title="Share">SHARE</a><span><a href="#" title="share"><img src="_common/images/providers/share.png" alt="" /></a></span>
<a href="#" title="Print">PRINT</a><span><a href="#" title="print"><img src="_common/images/providers/print.png" alt="" /></a></span>
</div>
</div>
<!--right side container end-->
<!--main-container-end-->
</div>
<div class="tab-wrapper" id="tab-menu">
<div class="resp-tabs-container">
<div class="tab">
<div class="tab-sub-text">
$_SerializerTool.serialize($bottomContent, true)
</div>
</div>
</div>
</div>
If I leave the block set to "content-center" and look at the
xml, I get this (no xml tree):
Office evaluation and treatment of cardiovascular, peripherial arterial and venous disease Adult invasive/intervential cardiology Diagnostic angiography Coronary angioplasty and stenting Pacemaker implantation Echocardiography (transthoracic, transesophageal, intracardiac and stress) Stress testing 24 hr., 48 hr., and 30 day cardiac monitoring and interpretation Electrical Cardioversion Emergent Pericardiocentesis Inferior Vena Cava Filter placement Lower extremity radiofrequency endovenous ablation Peripheral endovascular angioplasty and stenting (Lower extremity, renal, and subclavian artery interventions)/_common/blocks/conditions/heart-conditions1.citizensmemorial.comheart-conditionsConditions Treated at the CMH Heart Institute
-
page-with-block.jpg 43.6 KB
Discussions are closed to public comments.
If you need help with Cascade CMS please
start a new discussion.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
1 Posted by Ryan Griffith on 09 Feb, 2015 08:29 PM
Hi Lauren,
In order to pull in the block's content, you will need to tweak the XPath used within the first line of your Format to read into the block chooser's content element. Something like the following:
Where
BLOCK_CHOOSER
would be the identifier you used for the chooser field.Note: you will also need to ensure you specify a Render Content Depth for the chooser field itself to ensure the Format has access to the block's content. This can be accomplished by editing the Data Definition, edit the block chooser field, and fill in a value for Render Content Depth under the Advanced options. I generally use a value of 4-5.
Please let me know if you have any questions.
Thanks!
2 Posted by lauren.fraser on 09 Feb, 2015 09:51 PM
Ryan,
I changed the $data variable to the following:
```
#set ($data = $_XPathTool.selectSingleNode($contentRoot,"/system-data-structure/block-content/content"))
```
And here is the xml from the data definition
```
<system-data-structure>
<asset type="block" identifier="block-content" label="Content Block" render-content-depth="5"/>
</system-data-structure>
```
The content render depth is set to 5, but I’m still not seeing the content, just the velocity code - $_EscapeTool.xml($title.value)
I also tried selectNodes, without luck. What am I missing?
Thanks,
Lauren
3 Posted by Ryan Griffith on 10 Feb, 2015 08:36 PM
Hi Lauren,
My apologies, I wasn't sure if you wanted the chosen block's Title metadata field or an actual field within the block's structured data (ie data definition). If you are attempting to grad a title field, try adjusting the snippet I provided to the following:
Please let me know if you have any questions.
Thanks!
4 Posted by lauren.fraser on 10 Feb, 2015 09:01 PM
We’re actually trying to grab several fields from the data definition.
I tried the code you sent as well as what’s below (I wasn’t sure if I need to replace block-chooser with the name of the block from the data definition).
I couldn’t get it to with either one.
#set ($data = $_XPathTool.selectSingleNode($contentRoot,"/system-data-structure/block-content/content/system-data-structure"))
5 Posted by Ryan Griffith on 10 Feb, 2015 09:14 PM
Hm. Do you have a calling page Index Block applied to this page's region as well? If so, you most likely need to tweak the XPath a bit more to grab that chooser.
When you have a moment, try the following:
Please let me know if you have any questions.
Thanks!
6 Posted by lauren.fraser on 10 Feb, 2015 09:24 PM
Ryan,
Thanks that did the trick.
Lauren
7 Posted by Ryan Griffith on 10 Feb, 2015 09:32 PM
Not a problem at all, Lauren. I am glad to hear the latest code snippet did the trick.
I'm going to go ahead and close this discussion, please feel free to comment or reply to re-open if you have any additional questions.
Have a great day!
Ryan Griffith closed this discussion on 10 Feb, 2015 09:32 PM.