tag:help-archives.hannonhill.com,2010-02-09:/discussions/xslt-formats/4764-next-previous-buttonsCascade CMS: Discussion 2014-09-03T19:55:09Ztag:help-archives.hannonhill.com,2010-02-09:Comment/324709022014-04-09T12:32:34Z2014-04-09T12:32:34ZNEXT | PREVIOUS BUTTONS<div><p>Hi Bradley,</p>
<p>I think the <a href=
"http://www.w3schools.com/xpath/xpath_functions.asp#context">element's
position</a> may be able to provide you with that you are looking
for.</p>
<p>When you have a moment, would you be able to explain in further
detail what you are trying to implement so I can make sure I am
understanding correctly.</p>
<p>Thanks!</p></div>Ryan Griffithtag:help-archives.hannonhill.com,2010-02-09:Comment/324709022014-04-09T18:50:27Z2014-04-09T18:50:27ZNEXT | PREVIOUS BUTTONS<div><p>Yeah the may work. Not sure without trying it out.</p>
<p>Currently I am creating a blog like section of our site
organized by year. When they click on a year they will get a list
of articles. When they click on the article they will get the
article page that has two buttons (NEXT | PREVIOUS). When they
click next they will get the next article in the list. When they
click previous they the get the previous article. In setting this
up in Cascade I would like the buttons to auto generate the urls so
that the user doesn't have to worry about linking to the right
page. Make sense? Here is a dev url that I am working on. Not sure
if you can see it outside our office though. Give it a shot if you
like. <a href=
"http://dev.coldstonecreamery.com/getinthemix/index.html">http://dev.coldstonecreamery.com/getinthemix/index.html</a></p>
<p>Thanks for your help.</p></div>bwmyerstag:help-archives.hannonhill.com,2010-02-09:Comment/324709022014-04-09T19:22:54Z2014-04-09T19:22:54ZNEXT | PREVIOUS BUTTONS<div><p>Thank you for following up, Bradley, your additional information
was very helpful.</p>
<p>I think position will work in this case. So what I am thinking
you would do is loop over the pages, use the position for the
article container's ID, and add the prev and next links based on
the position. Consider the following snippet as a starting
point:</p>
<pre>
<code><xsl:template match="system-page">
<xsl:variable name="pos" select="position()" />
<xsl:variable name="prev">
<xsl:choose>
<xsl:when test="$pos &gt; 0"><xsl:value-of select="$pos - 1"/></xsl:when>
<xsl:otherwise>null</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="next">
<xsl:choose>
<xsl:when test="$pos != last()"><xsl:value-of select="$pos + 1"/></xsl:when>
<xsl:otherwise>null</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<div id="article-${pos}">
... Article content here ...
<xsl:if test="$prev != 'null'"><a href="#article-${prev}">Prev</a></xsl:if>
<xsl:if test="$next != 'null'"><a href="#article-${next}">Next</a></xsl:if>
</div>
</xsl:template></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/324709022014-04-16T12:10:45Z2014-04-16T12:10:45ZNEXT | PREVIOUS BUTTONS<div><p>Hi Bradley,</p>
<p>Just wanted to follow up to see if you had a chance to view my
<a href=
"http://help.hannonhill.com/discussions/xslt-formats/4764-next-previous-buttons#comment_32485211">
recent comment</a>. Were you able to get your slider working?</p>
<p>Please let us know if you have any questions.</p>
<p>Thanks.</p></div>Ryan Griffithtag:help-archives.hannonhill.com,2010-02-09:Comment/324709022014-07-28T18:02:11Z2014-07-28T18:03:23ZNEXT | PREVIOUS BUTTONS<div><p>Sorry about closing and reopening this. I reopened it on Friday
but while I was in the process of typing the post your system went
into maintenance mode so my post was rejected. Here is my
question:</p>
<p>I implemented the xslt. Made a few changes to try and get the
link from the previous and next position. For some reason it is
printing out the current page url for both buttons. Not sure how to
proceed. Here is a working example of a page generated by the cms
that includes the buttons: <a href=
"http://dev.coldstonecreamery.com/getinthemixcms/ourstory/ourculture/index.html">
http://dev.coldstonecreamery.com/getinthemixcms/ourstory/ourculture...</a></p>
<p>As an FYI, My folder structure looks like the folloiwng. So
Include the System-folder on the apply templates call.</p>
<pre>
<code>-Article Folder
--aricle folder index.html
--Article Sub Folder
---Article Sub Folder Index</code>
</pre>
<p>Here is an example of the xslt I am using. I imagine that my
issue exists in how I am trying to access the link for the previous
and next.</p>
<pre>
<code><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" >
<xsl:output encoding="utf-8" method="html"/>
<xsl:template match="/system-index-block">
<xsl:apply-templates select="system-page | system-folder"/>
</xsl:template>
<xsl:template match="system-page | system-folder">
<xsl:variable name="pos" select="position()"/>
<xsl:variable name="prev">
<xsl:choose>
<xsl:when test="$pos &gt; 0">
<xsl:value-of select="link[$pos - 1]"/>
</xsl:when>
<xsl:otherwise>null</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="next">
<xsl:choose>
<xsl:when test="$pos != last()">
<xsl:value-of select="link[$pos + 1]"/>
</xsl:when>
<xsl:otherwise>null</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<div class="floatLeft" id="blogDirectionControl">
<xsl:if test="$prev != 'null'">
<a class="btn" href="{$prev}">Prev</a>
</xsl:if>
<xsl:if test="$next != 'null'">
<a class="btn" href="{$next}">Next</a>
</xsl:if>
</div>
</xsl:template>
</xsl:stylesheet></code>
</pre></div>bwmyerstag:help-archives.hannonhill.com,2010-02-09:Comment/324709022014-07-29T19:29:35Z2014-07-29T19:29:35ZNEXT | PREVIOUS BUTTONS<div><p>Not a problem at all, Bradley.</p>
<p>I believe you will want something like the following to access
the previous and next link elements:</p>
<pre>
<code><xsl:value-of select="preceding-sibling::*[$pos - 1]/link"/>
<xsl:value-of select="following-sibling::*[$pos + 1]/link"/></code>
</pre>
<p>This should grab the page or symlink that directly precedes and
follows the current node.</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/324709022014-07-29T21:12:49Z2014-07-29T21:12:49ZNEXT | PREVIOUS BUTTONS<div><p>I will take a look. I figured it was a syntax thing. Just
didn’t know the words! ☺ As always thanks for your
help.</p>
<h2><a class="anchor" name="thanks-" href="#thanks-" id=
"thanks-"></a>Thanks,</h2>
<p>Bradley W. Myers<br>
Web Applications<br>
Kahala Corp.<br>
em: <a href=
"mailto:bmyers@kahalacorp.com">bmyers@kahalacorp.com</a><a href=
"mailto:bmyers@kahalacorp.com">bmyers@kahalacorp.com</a><br>
ph: 480.362.4609<br>
fx: 480.362.4848</p>
<p>[Kahala_Logo_retrofit-email copy]</p>
<p>The information contained in this electronic mail message is the
confidential and proprietary information of Kahala Corp and is
intended only for the use of the individual or entity named above.
If the reader of this message is not the intended recipient or the
employee or agent responsible to deliver it to the intended
recipient, you are hereby notified that any dissemination,
distribution or copying of this communication is strictly
prohibited. If you have received this communication in error,
please immediately notify us by telephone (480-362-4800) and delete
the original message. Thank you.</p></div>bwmyerstag:help-archives.hannonhill.com,2010-02-09:Comment/324709022014-07-30T15:41:28Z2014-07-30T15:41:28ZNEXT | PREVIOUS BUTTONS<div><p>Not a problem at all, Bradley. Please keep me posted on how the
proposed changes work out.</p>
<p>Thanks!</p></div>Ryan Griffithtag:help-archives.hannonhill.com,2010-02-09:Comment/324709022014-08-01T00:06:19Z2014-08-20T13:10:58ZNEXT | PREVIOUS BUTTONS<div><p>Ryan,</p>
<p>Doesn’t seem like the xslt worked properly.</p>
<p>Here is a working example: <a href=
"http://dev.coldstonecreamery.com/getinthemixcms/ourstory/">http://dev.coldstonecreamery.com/getinthemixcms/ourstory/</a></p>
<p>Looks like the second next button is linking correctly. But the
next page’s (<a href=
"http://dev.coldstonecreamery.com/getinthemixcms/ourstory/ourculture">http://dev.coldstonecreamery.com/getinthemixcms/ourstory/ourculture</a>)
buttons are linking to itself. Not sure why there are three either.
I imagine it has to do with the folder being nested but the logic
looks correct to me. Doesn’t look like the values of nxt and
prev value are being passed in as null.</p>
<p>Here is the xslt:</p>
<pre>
<code><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:addthis="http://www.addthis.com/help/api-spec">
<xsl:output encoding="utf-8" method="html"/>
<xsl:template match="/system-index-block">
<xsl:apply-templates select="system-page | system-folder"/>
</xsl:template>
<xsl:template match="system-page | system-folder">
<xsl:variable name="pos" select="position()"/>
<xsl:variable name="prev">
<xsl:choose>
<xsl:when test="$pos &gt; 0">
<xsl:value-of select="preceding-sibling::*[$pos - 1]/link"/>
</xsl:when>
<xsl:otherwise>null</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="next">
<xsl:choose>
<xsl:when test="$pos != last()">
<xsl:value-of select="following-sibling::*[$pos + 1]/link"/>
</xsl:when>
<xsl:otherwise>null</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<div class="floatLeft" id="blogDirectionControl">
<xsl:if test="$prev != 'null'">
<a class="btn" href="{$prev}">Prev</a>
</xsl:if>
<xsl:if test="$next != 'null'">
<a class="btn" href="{$next}">Next</a>
</xsl:if>
</div>
</xsl:template>
</xsl:stylesheet></code>
</pre>
<h2><a name="thanks-" class="anchor" href="#thanks-" id=
"thanks-"></a>Thanks,</h2>
<p>Bradley W. Myers<br>
Web Applications<br>
Kahala Corp.<br>
em: <a href=
"mailto:bmyers@kahalacorp.com">bmyers@kahalacorp.com</a><a href=
"mailto:bmyers@kahalacorp.com">bmyers@kahalacorp.com</a><br>
ph: 480.362.4609<br>
fx: 480.362.4848</p>
<p>[Kahala_Logo_retrofit-email copy]</p>
<p>The information contained in this electronic mail message is the
confidential and proprietary information of Kahala Corp and is
intended only for the use of the individual or entity named above.
If the reader of this message is not the intended recipient or the
employee or agent responsible to deliver it to the intended
recipient, you are hereby notified that any dissemination,
distribution or copying of this communication is strictly
prohibited. If you have received this communication in error,
please immediately notify us by telephone (480-362-4800) and delete
the original message. Thank you.</p></div>bwmyerstag:help-archives.hannonhill.com,2010-02-09:Comment/324709022014-08-01T18:53:19Z2014-08-01T18:53:19ZNEXT | PREVIOUS BUTTONS<div><p>Thank you for following up, Bradley.</p>
<p>When you have a moment, please attach a sample XML that you are
applying to this Format so I can do some local testing. You can
obtain the sample XML by editing the Format and using the preview
options.</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/324709022014-08-01T19:09:56Z2014-08-01T19:09:56ZNEXT | PREVIOUS BUTTONS<div><p>Would you rather I post via the web portal or can I just respond
to these emails? In this case I have attached the xml document. I
can post to web forum if you like. Not sure if email is integrated
with your forum.</p>
<h2><a class="anchor" name="thanks-" href="#thanks-" id=
"thanks-"></a>Thanks,</h2>
<p>Bradley W. Myers<br>
Web Applications<br>
Kahala Corp.<br>
em: <a href=
"mailto:bmyers@kahalacorp.com">bmyers@kahalacorp.com</a><a href=
"mailto:bmyers@kahalacorp.com">bmyers@kahalacorp.com</a><br>
ph: 480.362.4609<br>
fx: 480.362.4848</p>
<p>[Kahala_Logo_retrofit-email copy]</p>
<p>The information contained in this electronic mail message is the
confidential and proprietary information of Kahala Corp and is
intended only for the use of the individual or entity named above.
If the reader of this message is not the intended recipient or the
employee or agent responsible to deliver it to the intended
recipient, you are hereby notified that any dissemination,
distribution or copying of this communication is strictly
prohibited. If you have received this communication in error,
please immediately notify us by telephone (480-362-4800) and delete
the original message. Thank you.</p></div>bwmyerstag:help-archives.hannonhill.com,2010-02-09:Comment/324709022014-08-01T20:49:37Z2014-08-01T20:49:37ZNEXT | PREVIOUS BUTTONS<div><p>Hi Bradley,</p>
<p>Thank you for providing the sample XML. I may not get to test
today yet, but will make a note to look at it early next week.</p>
<blockquote>
<p>Would you rather I post via the web portal or can I just respond
to these emails? In this case I have attached the xml document. I
can post to web forum if you like. Not sure if email is integrated
with your forum.</p>
</blockquote>
<p>Responding the the emails does post directly to the forum as
well (along with the attachments). Feel free to use which ever
method you are comfortable with.</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/324709022014-08-20T13:50:18Z2014-08-20T13:50:18ZNEXT | PREVIOUS BUTTONS<div><p>Hi Bradley,</p>
<p>My apologies for not responding sooner.</p>
<p>I believe you are correct in that because the pages are within a
different folder structure you won't be able to use
<code>preceding|following-sibling</code> when obtaining the
previous and next pages. I believe this is because using
<code><xsl:apply-templates></code> just loops over the
nodes.</p>
<p>Instead, I think your best bet would be to pass all of the pages
into a template as a variable and loop through them. I have
attached an updated XSLT Format that may be able to give you a good
starting point.</p>
<p>Please let me know if you have any questions.</p>
<p>Thanks!</p></div>Ryan Griffith