tag:help-archives.hannonhill.com,2010-02-09:/discussions/velocity-formats/5530-getting-error-on-pageCascade CMS: Discussion 2013-09-16T14:56:56Ztag:help-archives.hannonhill.com,2010-02-09:Comment/287285632013-09-10T20:06:19Z2013-09-10T20:06:19ZGetting Error on Page<div><p>Hi,</p>
<p>Can you try changing your first line:<br></p>
<pre>
<code>#set ( $data = $_XPathTool.selectSingleNode($contentRoot, "/system-index-block/calling-page/system-page/system-data-structure/") )</code>
</pre>
to:<br>
<pre>
<code>#set ( $data = $_XPathTool.selectSingleNode($contentRoot, "/system-index-block/calling-page/system-page/system-data-structure") )</code>
</pre>
I'm wondering if that trailing '/' is causing issues. Let me know
if that does the trick.</div>Timtag:help-archives.hannonhill.com,2010-02-09:Comment/287285632013-09-10T20:22:43Z2013-09-10T20:22:43ZGetting Error on Page<div><p>Of course it did haha - another question related to the format.
How do you format the date from the date picker different ways?</p>
<p>Graham Lewis<br>
Webmaster<br>
Jacksonville State University</p>
<p>256.782.5331<br>
<a href="http://www.jsu.edu">www.jsu.edu</a></p></div>Graham Lewistag:help-archives.hannonhill.com,2010-02-09:Comment/287285632013-09-10T20:27:41Z2013-09-10T20:27:41ZGetting Error on Page<div><p>Hey Graham,</p>
<p>I think you'll want to check out the <a href=
"http://www.hannonhill.com/kb/Script-Formats/#date-tool">Date
Tool</a>. That page will help you with outputting the dates in
different formats.</p>
<p>Here's an example of someone asking a similar question on our
forums along with a response from Ryan (one of our support
engineers):</p>
<p><a href=
"http://help.hannonhill.com/discussions/velocity-formats/5332-formatting-dates-using-datetool#comment_28376841">
http://help.hannonhill.com/discussions/velocity-formats/5332-format...</a></p>
<p>Let me know if you need more help!</p></div>Timtag:help-archives.hannonhill.com,2010-02-09:Comment/287285632013-09-10T20:56:21Z2013-09-10T20:56:21ZGetting Error on Page<div><p>Not quite sure I understand how to use it lol.</p>
<p>Here is what I added to the format where I want to call the
dates</p>
<pre>
<code>
#set ( $open = $_DateTool.getDate($show.getChild('open').value) )
#set ( $close = $_DateTool.getDate($show.getChild('close').value) )</code>
</pre>
<p>Here is the error I am getting on the page</p>
<pre>
<code>
An error occurred: Could not transform with Script format "_internal/formats/site content/gallery-schedule-art": org.apache.velocity.exception.MethodInvocationException: Invocation of method 'getDate' in class com.hannonhill.cascade.velocity.CascadeComparisonDateTool threw exception java.lang.Exception: Could not parse date: '01-17-2013' :For input string: "01-17-2013" at velocityTransform-1378846396364[line 9, column 27]
You may choose to retry the operation . If the problem persists, please contact a system administrator.
The error has been logged to the system console.</code>
</pre>
<p>Graham Lewis<br>
Webmaster<br>
Jacksonville State University</p>
<p>256.782.5331<br>
<a href="http://www.jsu.edu">www.jsu.edu</a></p></div>Graham Lewistag:help-archives.hannonhill.com,2010-02-09:Comment/287285632013-09-11T02:55:46Z2013-09-11T02:55:46ZGetting Error on Page<div><p>Also, would it be possible to sort it by date? For example, if
it hasn't happened yet put it in an upcoming, if it has put it in a
past shows?</p>
<p>I'm trying to make it as easy and hands off on our end users as
possible. Haha</p>
<p>Sent from my iPhone</p></div>Graham Lewistag:help-archives.hannonhill.com,2010-02-09:Comment/287285632013-09-11T12:35:09Z2013-09-11T12:35:09ZGetting Error on Page<div><p>Here is the XML from the page if that will help - What I am
wanting to use is "open" "close" "reception-open" and
"reception-close"</p>
<pre>
<code>< system-index-block current-time =" 1378902697331 " name =" current page " type =" folder " >
< calling-page >
< system-page current =" true " id =" 0360d8120a55031f54d27cd61876079b " >
< name >
art_gallery </ name >
< is-published >
true </ is-published >
< last-published-on >
1378888228282 </ last-published-on >
< last-published-by >
system </ last-published-by >
< title >
Hammond Hall Art Gallery Schedule </ title >
< display-name >
Hammond Hall Art Gallery Schedule </ display-name >
< path >
/art_gallery </ path >
< site >
CAS - Art </ site >
< link >
site://CAS - Art/art_gallery </ link >
< created-by >
glewis </ created-by >
< created-on >
1378741180433 </ created-on >
< last-modified-by >
glewis </ last-modified-by >
< last-modified >
1378843785040 </ last-modified >
< dynamic-metadata >
< name >
navigation </ name >
< value >
Yes </ value > </ dynamic-metadata >
< system-data-structure definition-path =" Custom DDs/art-gallery-schedule " >
< year >
2013 </ year >
< show >
< title >
Graduate Show </ title >
< open >
01-17-2013 </ open >
< close >
01-24-2013 </ close >
< reception-start >
1359066600000 </ reception-start >
< reception-end >
1359073800000 </ reception-end > </ show > </ system-data-structure > </ system-page > </ calling-page > </ system-index-block ></code>
</pre>
<p>Graham Lewis<br>
Webmaster<br>
Jacksonville State University</p>
<p>256.782.5331<br>
<a href="http://www.jsu.edu">www.jsu.edu</a></p></div>Graham Lewistag:help-archives.hannonhill.com,2010-02-09:Comment/287285632013-09-12T14:25:29Z2013-09-12T14:25:29ZGetting Error on Page<div><p>Tim,</p>
<p>Have you had a chance to look at this anymore?</p></div>Graham Lewistag:help-archives.hannonhill.com,2010-02-09:Comment/287285632013-09-12T15:15:00Z2013-09-12T15:15:00ZGetting Error on Page<div><p>Hi Graham,</p>
<p>The underlying issue causing your latest error message is
<code>$_DateTool.getDate()</code> method is expecting a numeric
timestamp, but the value from a date picker is a String.</p>
<p>Try the following and let me know how it works out:</p>
<pre>
<code>#set ( $open = $_DateTool.toDate("MM-dd-yyyy", $show.getChild('open').value) )
#set ( $close = $_DateTool.toDate("MM-dd-yyyy", $show.getChild('close').value) )</code>
</pre>
<p>To summarize, we are converting the string to a date object
based on a specific format using the
<code>$_DateTool.toDate()</code> method.</p>
<p>Please let me know if you have any questions.</p>
<p>Thanks!</p></div>Ryan Griffithtag:help-archives.hannonhill.com,2010-02-09:Comment/287285632013-09-12T15:24:18Z2013-09-12T15:24:18ZGetting Error on Page<div><p>Thanks man - 2 things. That worked, but it added a 12:00AM to
the end of it, how do I get rid of that?</p>
<p>Also, I have two dates that is formatted like this
1359073800000, I'm thinking I need to use the dateTool for that too
but I tried to use the same you sent and it didn't work.</p>
<p>Graham Lewis<br>
Webmaster<br>
Jacksonville State University</p>
<p>256.782.5331<br>
<a href="http://www.jsu.edu">www.jsu.edu</a></p></div>Graham Lewistag:help-archives.hannonhill.com,2010-02-09:Comment/287285632013-09-12T15:31:15Z2013-09-12T15:31:15ZGetting Error on Page<div><p>Hi Graham,</p>
<blockquote>
<p>That worked, but it added a 12:00AM to the end of it, how do I
get rid of that?</p>
</blockquote>
<p>You will need to use the <code>$_DateTool.format()</code> method
to format your new Date object. <a href=
"http://velocity.apache.org/tools/devel/javadoc/org/apache/velocity/tools/generic/DateTool.html#format(java.lang.String,%20java.lang.Object)">
Here is a link to the documentation page</a> for additional
information. If you scroll down a bit, you will see the available
formatting symbols.</p>
<blockquote>
<p>Also, I have two dates that is formatted like this
1359073800000, I'm thinking I need to use the dateTool for that too
but I tried to use the same you sent and it didn't work.</p>
</blockquote>
<p>If you have a numeric timestamp, you would use the
<code>$_DateTool.getDate()</code> method to convert the value to a
Date object.</p>
<p>Please let me know if you have any questions.</p>
<p>Thanks!</p></div>Ryan Griffithtag:help-archives.hannonhill.com,2010-02-09:Comment/287285632013-09-12T15:45:06Z2013-09-12T15:45:06ZGetting Error on Page<div><p>Would I do it like this?</p>
<p>#set ( $recstart = $show.getChild("reception-start") )
$_DateTool.getDate($restart) Graham Lewis<br>
Webmaster<br>
Jacksonville State University</p>
<p>256.782.5331<br>
<a href="http://www.jsu.edu">www.jsu.edu</a></p></div>Graham Lewistag:help-archives.hannonhill.com,2010-02-09:Comment/287285632013-09-12T15:52:15Z2013-09-12T15:52:15ZGetting Error on Page<div><p>Close, you would use something like the following to convert the
value to a Date Object and then format it:</p>
<pre>
<code>#set ( $recstart = $show.getChild("reception-start") )
#set ( $recstart = $_DateTool.getDate($recstart.value) )
$_DateTool.format('EEEEE MM/dd/yy', $recstart)</code>
</pre>
<p>Or</p>
<pre>
<code>#set ( $recstart = $_DateTool.getDate($show.getChild("reception-start").value) )
$_DateTool.format('EEEEE MM/dd/yy', $recstart)</code>
</pre>
<p>Please let me know if you have any questions.</p>
<p>Thanks!</p></div>Ryan Griffithtag:help-archives.hannonhill.com,2010-02-09:Comment/287285632013-09-12T16:02:25Z2013-09-12T16:02:25ZGetting Error on Page<div><p>Perfect! One more then I shall leave you alone. If I want to add
an IF saying if there is nothing set for $recstart, how should it
be done? I figured this would work.</p>
<p>#if( $recstart.value != '' )</p>
<p>Graham Lewis<br>
Webmaster<br>
Jacksonville State University</p>
<p>256.782.5331<br>
<a href="http://www.jsu.edu">www.jsu.edu</a></p></div>Graham Lewistag:help-archives.hannonhill.com,2010-02-09:Comment/287285632013-09-12T17:47:17Z2013-09-12T17:47:17ZGetting Error on Page<div><p>That should work, but I would do it prior to using the DateTool.
I am not 100%, but passing in an empty string may default to the
current date. Also, it might not hurt to make sure
<strong>$recstart</strong> exists along with checking the
value:</p>
<pre>
<code>#if( $recstart && $recstart.value != '' )</code>
</pre>
<p>Please let me know if you have any questions.</p>
<p>Thanks!</p></div>Ryan Griffithtag:help-archives.hannonhill.com,2010-02-09:Comment/287285632013-09-12T17:48:54Z2013-09-12T17:48:54ZGetting Error on Page<div><p>Ah - I was thinking that but wasn't sure if having $recstart
exist again would mess anything up.I shall try it.</p>
<p>Graham Lewis<br>
Webmaster<br>
Jacksonville State University</p>
<p>256.782.5331<br>
<a href="http://www.jsu.edu">www.jsu.edu</a></p></div>Graham Lewistag:help-archives.hannonhill.com,2010-02-09:Comment/287285632013-09-12T17:53:38Z2013-09-12T17:53:38ZGetting Error on Page<div><p>Worked perfectly.</p>
<p>Graham Lewis<br>
Webmaster<br>
Jacksonville State University</p>
<p>256.782.5331<br>
<a href="http://www.jsu.edu">www.jsu.edu</a></p></div>Graham Lewistag:help-archives.hannonhill.com,2010-02-09:Comment/287285632013-09-12T18:58:03Z2013-09-12T18:58:03ZGetting Error on Page<div><p>Thank you for following up, Graham. I am glad to hear that did
the trick.</p>
<p>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.</p>
<p>Have a great day!</p></div>Ryan Griffithtag:help-archives.hannonhill.com,2010-02-09:Comment/287285632013-09-12T18:59:53Z2013-09-12T18:59:53ZGetting Error on Page<div><p>Sounds good! Thanks - see ya in a few days haha</p>
<p>Graham Lewis<br>
Webmaster<br>
Jacksonville State University</p>
<p>256.782.5331<br>
<a href="http://www.jsu.edu">www.jsu.edu</a></p></div>Graham Lewistag:help-archives.hannonhill.com,2010-02-09:Comment/287285632013-09-12T19:03:19Z2013-09-12T19:03:19ZGetting Error on Page<div><p>I was wondering if you were going to attend the conference.
Looking forward to seeing you soon!</p></div>Ryan Griffith