tag:help-archives.hannonhill.com,2010-02-09:/discussions/how-do-i/15300-include-an-image-in-an-xml-outputCascade CMS: Discussion 2015-03-03T14:51:31Ztag:help-archives.hannonhill.com,2010-02-09:Comment/354876212014-12-08T15:53:18Z2014-12-08T16:37:46Zinclude an image in an xml output.<div><p>I'm working with our IT department with the creation of a new
mobile application and I'm providing them with XML outputs of
specific pages within our Royal News website. I've been able to
create these easily enough but this particular case is slightly
different and I'm not sure what I need to do.</p>
<p>We have index pages that list the article's in that particular
week's issue. Here's the example of the <a href=
"http://www.scranton.edu/news/royalnews/releases/2014/11/12/index.shtml">
second week of November</a></p>
<p>The idea is to have a featured image on this page for the app. I
created a Data Definition that allows an image to be inserted but
we only want the image to appear in an XML output. How would I go
about that?</p>
<p>I've attached a screenshot of the index block (which pulls any
article the index page shares) and the format is:</p>
<pre>
<code>#set ( $PageItems = $_XPathTool.selectNodes($contentRoot, "/system-index-block/system-page[name != 'index']") )
#set ( $ListItems = $_XPathTool.selectNodes($contentRoot, "/system-index-block/system-folder[name != 'images']") )
#set ( $PageTitle = $_XPathTool.selectSingleNode($contentRoot, "//calling-page/system-page/display-name") )
<h1>$PageTitle.value</h1>
## for folders
#if ( $ListItems )
<ul>
#foreach( $Item in $ListItems )
#set ( $Issue = $Item.getChild('title').text )
#set ( $ItemURL = $Item.getChild('link') )
<li>
<a href="${ItemURL.value}">${Issue}</a>
</li>
#end
</ul>
#end
## for pages
#if ( $PageItems )
<ul>
#foreach( $Page in $PageItems )
#set ( $PageT = $Page.getChild('title').text )
#set ( $PageURL = $Page.getChild('link') )
<li>
<a href="${PageURL.value}">
$_SerializerTool.serialize($Page.getChild("title"),true)
</a>
</li>
#end
</ul>
#end
#*
#if ( $Imgs )
#foreach ( $Img in $Imgs )
#set ( $ImgName = $Img.getChild('name') )
#set ( $ImgURL = $Img.getChild('link') )
##<br/>$ImgName.value<br/>
## $ImgURL.value<br/>
#if ( $ImgName.value == 'cover.jpg' )
<br/>
<a href="${ItemURL.value}"><img src="${ImgURL.value}" alt="Cover"/></a>
#end
#end
#end
*#</code>
</pre>
<p>Currently the XML output has only the index applied.</p></div>matthew.wrentag:help-archives.hannonhill.com,2010-02-09:Comment/354876212014-12-10T02:30:30Z2014-12-10T02:30:30Zinclude an image in an xml output.<div><p>Hi Matthew,</p>
<p>I'm not sure I understand the question. Which data definition
did you attach the image chooser to? The index page or the article
pages?</p>
<p>Also what is $Imgs supposed to represent? A folder containing
images or a group of images? In your request, it sounded like you
wanted 1 image, but you are using a loop in your format, so it must
be a group of images. Can you provide more details of where the
images are coming from?</p>
<p>Thanks,</p>
<p>Lisa</p></div>Lisa McWilliams tag:help-archives.hannonhill.com,2010-02-09:Comment/354876212014-12-10T14:34:18Z2014-12-10T14:34:18Zinclude an image in an xml output.<div><p>Hi Lisa,</p>
<p>I think that's just a coincidence that there's a commented-out
section dealing with an image! Sorry I didn't even notice it. I
haven't actually done anything with the script yet.</p>
<p>Here's the entire Data Definition I created for these index
pages:<br></p>
<pre>
<code><system-data-structure>
<asset type="file" identifier="featured-index-image" label="Featured image for Each Issue"/>
</system-data-structure></code>
</pre>
<p>I am just wondering how I can include that image into only the
xml output</p></div>matthew.wrentag:help-archives.hannonhill.com,2010-02-09:Comment/354876212014-12-10T17:17:10Z2014-12-10T17:20:30Zinclude an image in an xml output.<div><p>Thanks for clearing that up. There are two ways to accomplish
your goals. One is to go to the block you are using to pull the
articles and check the 'append calling page' box (if it isn't
already selected). That will add the index page's data definition
to your block and then you can access it normally via xpath like
so:</p>
<pre>
<code> #set($page = $_XPathTool.selectSingleNode($contentRoot, "/system-index-block/calling-page/system-page") )
#set($img = $XPathTool.selectSingleNode($page, "system-data-structure/featured-index-image))</code>
</pre>
<p>Then to add the image you just output the link</p>
<pre>
<code> #if($img.getChild("link"))
#set($link = $img.getChild("link").value)
<img src="${link}" />
#end</code>
</pre>
<p>The other option is to use the locator tool.</p>
<pre>
<code>#set($img = $currentPage.getStructuredDataNode("featured-index-image"))
#if($img.asset.link)
#set($link = $img.asset.link)
<img src="${link}" />
#end</code>
</pre></div>Lisa McWilliams tag:help-archives.hannonhill.com,2010-02-09:Comment/354876212014-12-11T19:21:10Z2014-12-11T19:21:10Zinclude an image in an xml output.<div><p>I added those snippets into my format but I'm not seeing the
node appear in the <a href=
"http://www.scranton.edu/news/royalnews/releases/2014/11/12/index.xml">
xml page</a></p>
<p>Am I missing something?</p></div>matthew.wrentag:help-archives.hannonhill.com,2010-02-09:Comment/354876212014-12-11T20:24:56Z2014-12-11T20:24:56Zinclude an image in an xml output.<div><p>Hi Matthew,</p>
<p>It looks like your index block being applied to the format
probably does<br>
not have 'Render page XML inline only for current page' selected.
I've<br>
attached a copy of the index block, you need to select the Render
page XML<br>
inline only for current page option next to 'Page XML'.</p>
<p>I've attached an image copy of a block with that option
selected. You don't<br>
need to change the other areas of your block, only the area 'Page
XML'. I<br>
just included a picture of the whole thing so you would know what I
was<br>
showing you.</p>
<p>[image: Inline image 1]</p>
<p>Lisa McWilliams<br>
Services Project Manager</p>
<p><a href="http://hannonhill.com">http://hannonhill.com</a></p></div>Lisa McWilliams tag:help-archives.hannonhill.com,2010-02-09:Comment/354876212014-12-11T20:29:36Z2014-12-11T20:29:36Zinclude an image in an xml output.<div><p>that worked! Excellent thank you so much! I think that's all I
need for now but thanks again!</p></div>matthew.wrentag:help-archives.hannonhill.com,2010-02-09:Comment/354876212014-12-11T20:31:20Z2014-12-11T20:31:20Zinclude an image in an xml output.<div><p>You're welcome :) I'm going to close this now and if you have
different issue you can open a new discussion.</p></div>Lisa McWilliams tag:help-archives.hannonhill.com,2010-02-09:Comment/354876212014-12-12T20:59:35Z2014-12-12T20:59:35Zinclude an image in an xml output.<div><p>Okay so there's been a misunderstanding on my part. We aren't
looking to have a image picker from the index page included in the
XML, rather, each article has their own featured image and that
needs to be included with their corresponding node.</p>
<p>So if you look at this <a href=
"http://www.scranton.edu/news/royalnews/releases/2014/11/12/index.xml">
page again</a>, you'll see the various articles include within that
week's issue. Is there a way I can include the image from each
article into that xml output?</p></div>matthew.wrentag:help-archives.hannonhill.com,2010-02-09:Comment/354876212014-12-12T21:14:40Z2014-12-12T21:14:40Zinclude an image in an xml output.<div><p>Hi Matt,</p>
<p>To get them all to display, just change that same block. Instead
of<br>
selecting Render page XML inline only for current page' for the
Page XML<br>
option, instead choose Render page XML inline. This will display
the data<br>
definition for all of the articles and will show the article's
images.</p>
<p>Let me know if that's what you are looking for,</p>
<p>Lisa</p>
<p>Lisa McWilliams<br>
Services Project Manager</p>
<p><a href="http://hannonhill.com">http://hannonhill.com</a></p></div>Lisa McWilliams tag:help-archives.hannonhill.com,2010-02-09:Comment/354876212014-12-12T21:30:19Z2014-12-12T21:30:19Zinclude an image in an xml output.<div><p>I must not have the right option selected because now it only
<a href=
"http://www.scranton.edu/news/royalnews/releases/2014/11/12/index.xml">
shows one article</a> but it does show all of its content!</p>
<p>I'll attach the image to of the block again, maybe I'm missing
something else.</p></div>matthew.wrentag:help-archives.hannonhill.com,2010-02-09:Comment/354876212014-12-12T21:45:23Z2014-12-12T21:45:23Zinclude an image in an xml output.<div><p>It looks like the issue is that one of your articles has code
that is not<br>
xml compliant. Because there is an error, the rest of the articles
are not<br>
displaying. The only solution here is to go into that article (and
perhaps<br>
all of your articles) and check the wysiwyg content. The error
message<br>
suggests maybe there is a fb like button in the articles?</p>
<p>I'm thinking the 'tidy html' checkbox option for your pages is
unchecked,<br>
so that you can add whatever code you want without it getting
stripped by<br>
the editor. But this can lead to non compliant code that the xml
cannot<br>
parse. It's only an issue if you want to output xml like you are
doing now.</p>
<p>Checking all of the articles can be rather tedious, can I ask
why you are<br>
trying to get this xml block to display? What are you using it
for?</p>
<p>Thanks,</p>
<p>Lisa</p>
<p>Lisa McWilliams<br>
Services Project Manager</p>
<p><a href="http://hannonhill.com">http://hannonhill.com</a></p></div>Lisa McWilliams tag:help-archives.hannonhill.com,2010-02-09:Comment/354876212014-12-15T14:02:37Z2014-12-15T14:02:37Zinclude an image in an xml output.<div><p>I'm providing content to our IT department so they can include
the issues in our new mobile app they are working on along with an
outside developer.</p>
<p>We are trying to order the articles to how they are listed on
the main page every week (featured release & 3 other main
releases). The main index page, however, changes week-to-week so
there isn't a way to reflect this in the app. They asked me to
provide them with an XML output of the release page and have it
ordered manually with the featured article as number 1 and the
other three after that.</p>
<p>The content seems to pull just fine but those 4 articles always
have an image associated with them and we want those included
alongside the weekly article listing. We are just trying to avoid
adding more steps along with our normal workflow for Royal
News.</p></div>matthew.wrentag:help-archives.hannonhill.com,2010-02-09:Comment/354876212014-12-15T14:15:29Z2014-12-15T14:15:29Zinclude an image in an xml output.<div><p>Hi Matthew,</p>
<p>Thanks for explaining. What do you mean by "the content pulls
fine"? From<br>
what I saw in your screenshot, the xml will not display because
the<br>
articles contain content that is not xml compliant. It looked like
maybe a<br>
facebook share button/code or something is in the wysiwyg. You can
copy the<br>
wysiwyg content and run it through an xml validator tool to verify.
But in<br>
order to get the articles to show up the way you want them, the
content<br>
will need to be compliant.</p>
<p>Otherwise you can create a format and build your xml document
there. That<br>
way you can wrap the content in : $_EscapeTool.xml()</p>
<p>Lisa McWilliams<br>
Services Project Manager</p>
<p><a href="http://hannonhill.com">http://hannonhill.com</a></p></div>Lisa McWilliams tag:help-archives.hannonhill.com,2010-02-09:Comment/354876212014-12-15T14:21:36Z2014-12-15T14:21:36Zinclude an image in an xml output.<div><p>I meant it pulled fine previously when it was just the article
links without the page's content.</p>
<p>How would I create a format to create this XML document? That
seems like the best route in this case because I'm not sure what
the content will contain weekly.</p></div>matthew.wrentag:help-archives.hannonhill.com,2010-02-09:Comment/354876212015-02-26T16:27:15Z2015-02-26T16:27:15Zinclude an image in an xml output.<div><p>Hi Matthew,</p>
<p>Just wanted to check in here and see if you were able to get
things working on your end. Let us know how things are going.</p>
<p>Thanks</p></div>Timtag:help-archives.hannonhill.com,2010-02-09:Comment/354876212015-03-03T14:47:23Z2015-03-03T14:47:23Zinclude an image in an xml output.<div><p>Hey Tim,</p>
<p>Yes I believe I have! thank you very much!</p></div>matthew.wrentag:help-archives.hannonhill.com,2010-02-09:Comment/354876212015-03-03T14:51:30Z2015-03-03T14:51:30Zinclude an image in an xml output.<div><p>Glad to hear it! Thanks for the update, Matthew. Take care!</p></div>Tim