tag:help-archives.hannonhill.com,2010-02-09:/discussions/xslt-formats/6038-finding-hrefs-that-contain-specific-folder-in-pathCascade CMS: Discussion 2018-10-18T20:37:32Ztag:help-archives.hannonhill.com,2010-02-09:Comment/367874502015-05-08T18:33:10Z2015-05-08T18:33:10ZFinding HREFs that contain specific folder in path<div><p>Hi!</p>
<p>I'm trying to accomplish two things in the attached XSLT format.
First, I'm looking for text references that point to our website.
Second, I want to find HREFs that include specific folders from our
website. The first part works, the second does not. Instead, it
lists all pages from the index block, not just those containing
HREFs with the target folder. Only a few pages actually include the
/products/ folder specified in the format.</p>
<p>Can you help me fix the XSLT so that it finds the HREFs?</p>
<p>Thanks!</p></div>craig.haisstag:help-archives.hannonhill.com,2010-02-09:Comment/367874502015-05-08T19:34:57Z2015-05-08T19:34:57ZFinding HREFs that contain specific folder in path<div><p>Hi Craig,</p>
<p>I haven't had much time to dig into this, but I did take a quick
peek at your Format and I'm wondering what happens if you change
this line:<br></p>
<pre>
<code><xsl:if test="//a[contains(@href,'/products/')]"></code>
</pre>
to this:<br>
<pre>
<code><xsl:if test="a[contains(@href,'/products/')]"></code>
</pre>
Can you give that a shot and let me know if that changes the
behavior?
<p>If you still have trouble, please attach the Index Block that
you are transforming along with your expected output and the actual
output.</p>
<p>Thanks!</p></div>Timtag:help-archives.hannonhill.com,2010-02-09:Comment/367874502015-05-13T20:33:53Z2015-05-13T20:33:53ZFinding HREFs that contain specific folder in path<div><p>Thanks for taking time to look at this, Tim.</p>
<p>I made the suggested change (from "//a" to just "a"). After
that, instead of listing all content blocks as containing /product/
links, the page listed no content blocks. It should list only
content blocks that have a hyperlink pointing to "/products/".</p>
<p>I'm attaching two files. The first is the Index block. The
second is what I'd like the resulting table to look like, with the
text in the "Title of content block" column hyperlinked to the
actual blocks in the CMS.</p>
<p>Thanks so much for your help!</p></div>craig.haisstag:help-archives.hannonhill.com,2010-02-09:Comment/367874502015-06-02T19:22:36Z2015-06-02T19:22:36ZFinding HREFs that contain specific folder in path<div><p>Hi Craig,</p>
<p>Tim will be on vacation for the week so I wanted to follow up
here.</p>
<p>After taking a look at your Format, I believe what you will want
to do is adjust your <code><xsl:if></code> from:</p>
<pre>
<code><xsl:if test="//a[contains(@href,'/products/')]"></code>
</pre>
<p>to:</p>
<pre>
<code><xsl:if test=".//a[contains(@href,'/products/')]"></code>
</pre>
<p>When using <code>//a</code>, the XPath will return all
<code><a></code> elements at any level, whereas
<code>.//a</code> will return all <code><a></code> elements
at any level starting at the current node.</p>
<p>Please let me know if you have any questions or if the code
adjustment does not work out.</p>
<p>Thanks!</p></div>Ryan Griffithtag:help-archives.hannonhill.com,2010-02-09:Comment/367874502015-06-03T20:52:53Z2015-06-03T20:52:53ZFinding HREFs that contain specific folder in path<div><p>Awesome, that worked perfectly! Thanks so much for helping me
sort this out. I'll mark this one as 'closed.'</p></div>craig.haiss