Finding HREFs that contain specific folder in path
Hi!
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.
Can you help me fix the XSLT so that it finds the HREFs?
Thanks!
- xslt_format.txt 4.37 KB
Discussions are closed to public comments.
If you need help with Cascade CMS please
start a new discussion.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
Support Staff 1 Posted by Tim on 08 May, 2015 07:34 PM
Hi Craig,
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:
to this:Can you give that a shot and let me know if that changes the behavior?
If you still have trouble, please attach the Index Block that you are transforming along with your expected output and the actual output.
Thanks!
2 Posted by craig.haiss on 13 May, 2015 08:33 PM
Thanks for taking time to look at this, Tim.
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/".
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.
Thanks so much for your help!
3 Posted by Ryan Griffith on 02 Jun, 2015 07:22 PM
Hi Craig,
Tim will be on vacation for the week so I wanted to follow up here.
After taking a look at your Format, I believe what you will want to do is adjust your
<xsl:if>
from:to:
When using
//a
, the XPath will return all<a>
elements at any level, whereas.//a
will return all<a>
elements at any level starting at the current node.Please let me know if you have any questions or if the code adjustment does not work out.
Thanks!
4 Posted by craig.haiss on 03 Jun, 2015 08:52 PM
Awesome, that worked perfectly! Thanks so much for helping me sort this out. I'll mark this one as 'closed.'
craig.haiss closed this discussion on 03 Jun, 2015 08:52 PM.