tag:help-archives.hannonhill.com,2010-02-09:/discussions/velocity-formats/10195-changing-class-names-in-format-using-velocityCascade CMS: Discussion 2015-04-27T19:18:41Ztag:help-archives.hannonhill.com,2010-02-09:Comment/336450042014-07-03T15:13:10Z2014-07-03T15:13:10Zchanging class names in format using velocity<div><p>Hi Matthew,</p>
<p>If I understand correctly, you should just be able to create a
variable to store the effect (much like you are setting the author,
datetime, etc) and then place that effect variable in your
<code><div></code> statement. At that point, for example,
this line:<br></p>
<pre>
<code><div class="container intro-effect-fadeout" id="container"></code>
</pre>
would maybe look something like this:<br>
<pre>
<code><div class="container intro-effect-$effect" id="container"></code>
</pre>
(where $effect is the variable you've created that contains the
setting from the Page)
<p>Hope this helps!</p></div>Timtag:help-archives.hannonhill.com,2010-02-09:Comment/336450042014-07-03T15:21:57Z2014-07-03T15:21:57Zchanging class names in format using velocity<div><p>okay that's what I thought!</p>
<p>I added this to the format<br>
<code><div class="container intro-effect-$effect"
id="container"></code></p>
<p>but I don't' think I have this snippet written correctly<br>
<code>#set($effect =
$_XPathTool.selectSingleNode($contentRoot,"//dropdown").value)</code></p>
<p>do I have to do something differently since it's a dropdown?</p></div>matthew.wrentag:help-archives.hannonhill.com,2010-02-09:Comment/336450042014-07-03T15:46:14Z2014-07-03T15:46:14Zchanging class names in format using velocity<div><blockquote>
<p>do I have to do something differently since it's a dropdown?</p>
</blockquote>
<p>I would recommend taking a look at the XML output for a Page
where you've selected an effect. This will give you an idea of how
you'll need to write your XPath statement. If you still have
trouble, feel free to attach the XML output for one of these Pages
and I'll be happy to take a look.</p>
<p>Thanks!</p></div>Timtag:help-archives.hannonhill.com,2010-02-09:Comment/336450042014-07-03T17:19:58Z2014-07-03T17:19:58Zchanging class names in format using velocity<div><p>I'm tried a few things with no success.</p>
<p>this is the data structure XML<br></p>
<pre>
<code><system-data-structure>
<text type="dropdown" identifier="effect" label="Choose Effect">
<dropdown-item value="push"/>
<dropdown-item value="fadeout"/>
<dropdown-item value="sliced"/>
<dropdown-item value="side"/>
<dropdown-item value="sidefixed"/>
<dropdown-item value="grid"/>
<dropdown-item value="jam3"/>
</text>
<text identifier="headline" label="Headline" default="Headline Goes Here" required="true"/>
<text identifier="tagline" label="Tagline "/>
<text identifier="author" label="Author"/>
<asset type="file" identifier="mainImage" label="Main Image"/>
<text type="datetime" identifier="publication-date" label="Publication Date"/>
<text wysiwyg="true" identifier="main-content" label="Main Content"/>
</system-data-structure></code>
</pre>
<p>The Velocity Format<br></p>
<pre>
<code>#set($author = $_XPathTool.selectSingleNode($contentRoot,"//author").value)
#set($datetime = $_XPathTool.selectSingleNode($contentRoot,"//datetime").value)
#set($mainContent = $_XPathTool.selectSingleNode($contentRoot,"//system-page/system-data-structure/main-content"))
#set($mainImage = $_XPathTool.selectSingleNode($contentRoot,"//mainImage/link").value)
#set($mainTitle = $_XPathTool.selectSingleNode($contentRoot,"//headline").value)
#set($tagline = $_XPathTool.selectSingleNode($contentRoot,"//tagline").value)
#set($effect = $_XPathTool.selectSingleNode($contentRoot,"//dropdown").value)
<div class="container intro-effect-$effect" id="container">
<!-- Top Navigation -->
<header class="header">
<div class="bg-img">
<img src="$mainImage" alt="Celebrating 125 years" />
</div>
<div class="title">
<h1>$mainTitle</h1>
<p class="subline">
<p class="subline">$tagline</p>
</p>
<p>by <strong>$author</strong> &#8212; Posted in <strong>Animals</strong> on <strong>$datetime</strong></p>
</div>
</header>
<article class="content">
<div>
$_SerializerTool.serialize( $mainContent, true)
</div>
</article>
</div></code>
</pre>
<p>And the format with the xml output from the page.<br></p>
<pre>
<code><system-index-block current-time="1404407969444" name="calling-page" type="folder">
<calling-page>
<system-page current="true" id="ece79bc586c604b2389460029acae13f">
<name>index</name>
<system-data-structure definition-path="article-intro-effects/article">
<effect>fadeout</effect>
<headline>Headline Goes Here</headline>
<tagline>hello this is tagline</tagline>
<author>Matthew Wren</author>
<mainImage type="file">
<content/>
<path>/_private/experimental-page/img/2.jpg</path>
<link>site://www.scranton.edu/_private/experimental-page/img/2.jpg</link>
<site>www.scranton.edu</site>
<name>2.jpg</name>
</mainImage>
<publication-date>1403668800000</publication-date>
<main-content>
<p>We may define a food to be any substance which will repair the functional waste of the body, increase its growth, or maintain the heat, muscular, and nervous energy.</p>
<p>In its most comprehensive sense, the oxygen of the air is a food; as although it is admitted by the lungs, it passes into the blood, and there re-acts upon the other food which has passed through the stomach. It is usual, however, to restrict the term food to such nutriment as enters the body by the intestinal canal. Water is often spoken of as being distinct from food, but for this there is no sufficient reason.</p>
<p>Many popular writers have divided foods into flesh-formers, heat-givers, and bone-formers. Although attractive from its simplicity, this classification will not bear criticism. Flesh-formers are also heat-givers. Only a portion of the mineral matter goes to form bone.</p>
<p>These last are not strictly foods, if we keep to the definition already given; but they are consumed with the true foods or nutrients, comprised in the other two classes, and cannot well be excluded from consideration.</p>
<p>Water forms an essential part of all the tissues of the body. It is the solvent and carrier of other substances.</p>
<p>Mineral Matter or Salts, is left as an ash when food is thoroughly burnt. The most important salts are calcium phosphate, carbonate and fluoride, sodium chloride, potassium phosphate and chloride, and compounds of magnesium, iron and silicon.</p>
<h3>Flesh-formers, heat-givers, and bone-formers</h3>
<p>Mineral matter is quite as necessary for plant as for animal life, and is therefore present in all food, except in the case of some highly-prepared ones, such as sugar, starch and oil. Children require a good proportion of calcium phosphate for the growth of their bones, whilst adults require less. The outer part of the grain of cereals is the richest in mineral constituents, white flour and rice are deficient. Wheatmeal and oatmeal are especially recommended for the quantity of phosphates and other salts contained in them. Mineral matter is necessary not only for the bones but for every tissue of the body.</p>
<p>When haricots are cooked, the liquid is often thrown away, and the beans served nearly dry, or with parsley or other sauce. Not only is the food less tasty but important saline constituents are lost. The author has made the following experiments:&#8212;German whole lentils, Egyptian split red lentils and medium haricot beans were soaked all night (16 hours) in just sufficient cold water to keep them covered. The water was poured off and evaporated, the residue heated in the steam-oven to perfect dryness and weighed. After pouring off the water, the haricots were boiled in more water until thoroughly cooked, the liquid being kept as low as possible. The liquid was poured off as clear as possible, from the haricots, evaporated and dried. The ash was taken in each case, and the alkalinity of the water-soluble ash was calculated as potash (K2O). The quantity of water which could be poured off was with the German lentils, half as much more than the original weight of the pulse; not quite as much could be poured off the others.</p>
</main-content>
</system-data-structure>
</system-page>
</calling-page>
</system-index-block></code>
</pre></div>matthew.wrentag:help-archives.hannonhill.com,2010-02-09:Comment/336450042014-07-03T19:19:07Z2014-07-03T19:19:07Zchanging class names in format using velocity<div><p>So, it looks like in your Format you've done this:<br></p>
<pre>
<code>#set($effect = $_XPathTool.selectSingleNode($contentRoot,"//dropdown").value)</code>
</pre>
But if you look at the actual output of the Page in question,
you'll see that there is no 'dropdown' element. Instead, the effect
is located here:<br>
<pre>
<code><system-data-structure definition-path="article-intro-effects/article">
<effect>fadeout</effect>
...
</system-data-structure></code>
</pre>
So, you'll need to change your XPath statement to something like
this:<br>
<pre>
<code>#set($effect = $_XPathTool.selectSingleNode($contentRoot, "//effect").value)</code>
</pre>
Let me know if that makes sense.
<p>Thanks</p></div>Timtag:help-archives.hannonhill.com,2010-02-09:Comment/336450042014-07-03T19:34:00Z2014-07-03T19:34:00Zchanging class names in format using velocity<div><p>of course that makes sense...and works! Thank you! Are there
more resources about velocity (and maybe xslt)? I've been looking
at <a href=
"http://www.hannonhill.com/kb/Script-Formats/">http://www.hannonhill.com/kb/Script-Formats/</a>
but it's the only thing I've found about Velocity.</p></div>matthew.wrentag:help-archives.hannonhill.com,2010-02-09:Comment/336450042014-07-03T19:55:08Z2014-07-03T19:55:08Zchanging class names in format using velocity<div><p>Glad I could help!</p>
<p>You can check out the <a href=
"http://velocity.apache.org/engine/devel/user-guide.html">Apache
Velocity site</a> for a decent intro to using Velocity. Just keep
in mind that not all of the libraries they use throughout the
Apache docs are available within Cascade Server.</p>
<p>XSLT, on the other hand, has numerous resources available. The
first one that comes to mind:</p>
<p><a href=
"http://www.w3schools.com/xsl/">http://www.w3schools.com/xsl/</a></p>
<p>And actually, if you check out <a href=
"http://stackoverflow.com/questions/51271/what-is-a-good-resource-for-learning-xsl">
this post</a>, you'll see folks mentioning a bunch of other
resources that they find useful.</p>
<p>Hope this helps!</p></div>Tim