tag:help-archives.hannonhill.com,2010-02-09:/discussions/xslt-formats/5497-hide-headings-if-no-matching-linksCascade CMS: Discussion 2014-10-23T11:54:11Ztag:help-archives.hannonhill.com,2010-02-09:Comment/350214392014-10-21T18:13:57Z2014-10-21T18:13:57ZHide headings if no matching links<div><p>Hi Robert,</p>
<p>Using <code><xsl:key></code> is definitely the way to go.
I've had some previous success with a slightly different variation
of what you have, which I believe would make it easier to check the
count as well as maintain the code in general since it's a little
simpler.</p>
<p>When you have a moment, give the attached Format a try for
starters and let me know how it works out.</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/350214392014-10-21T18:50:06Z2014-10-21T19:27:47ZHide headings if no matching links<div><p>It's a good start. Only issue is that it displays the headings
multiple times. So if there are 2 article links, it displays:</p>
<p>Articles<br>
- Link 1 - Link 2</p>
<p>Articles<br>
- Link 1 - Link 2</p></div>rgraves2tag:help-archives.hannonhill.com,2010-02-09:Comment/350214392014-10-21T18:58:48Z2014-10-21T18:58:48ZHide headings if no matching links<div><p>Ah, my apologies Robert. I think i need to tweak the way the key
is generated. When you have a moment, try the attached Format and
let me know how it works out.</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/350214392014-10-21T19:22:14Z2014-10-22T18:47:34ZHide headings if no matching links<div><p>It's coming up blank now.</p>
<p>I should mention the folder structure I'm using for the links.
I'm storing them all in a folder called "resources". Originally I
was putting them all in that folder but decided to make subfolders
for each subject. So it is now:</p>
<p>/resources/english/ - Link 1 - Link 2 - Link 3 ...
/resources/mathematics/ ...</p>
<p>Does this make a difference?</p></div>rgraves2tag:help-archives.hannonhill.com,2010-02-09:Comment/350214392014-10-21T19:28:41Z2014-10-21T19:28:43ZHide headings if no matching links<div><p>It's not displaying anything now.</p></div>rgraves2tag:help-archives.hannonhill.com,2010-02-09:Comment/350214392014-10-21T19:44:32Z2014-10-21T19:44:32ZHide headings if no matching links<div><p>Bummer, sorry about that.</p>
<p>When you have a moment, if you could provide a sample XML being
applied to this Format I would be more than happy to continue to
work on it in my local instance. You can obtain the sample XML by
editing the Format and, using the <em>Preview Options</em> at the
top of the form, selecting the appropriate context assets (ie index
block and context page).</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/350214392014-10-21T19:53:10Z2014-10-21T19:53:11ZHide headings if no matching links<div><p>I've attached two samples.</p>
<p>English should have some articles, encyclopedia and websites.
The Classical Studies one only has Encyclopedia, so only that
heading should appear.</p>
<p>As you can see, I've grouped the links under the /resources/
folders so the format should only have to look in the respective
subject folder to find its links.</p></div>rgraves2tag:help-archives.hannonhill.com,2010-02-09:Comment/350214392014-10-21T19:54:11Z2014-10-21T19:54:12ZHide headings if no matching links<div><p>Files attached. The captchas are hard to read and messing up my
posts if I get them wrong.</p></div>rgraves2tag:help-archives.hannonhill.com,2010-02-09:Comment/350214392014-10-22T13:43:07Z2014-10-22T13:43:07ZHide headings if no matching links<div><p>Thank you for providing the sample XML, Robert.</p>
<p>After a little bit of tinkering, I believe I was able to get the
Format working as expected. When you have a moment, give the
attached Format a try and let me know how it works out.</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/350214392014-10-22T15:11:11Z2014-10-22T15:11:14ZHide headings if no matching links<div><p>Looks like this works. Thanks so much for your prompt
replies.</p>
<p>By chance, can you explain how the key() function works? I've
read a bit about it but I don't understand how the information is
stored which made it difficult for me to figure out how to use
it.</p>
<p>Thanks</p></div>rgraves2tag:help-archives.hannonhill.com,2010-02-09:Comment/350214392014-10-22T18:31:18Z2014-10-22T18:31:18ZHide headings if no matching links<div><p>Thank you for following up, Robert. I am glad to hear the
updated Format did the trick.</p>
<p>I'd have to say <code><xsl:key></code> is probably one of
the most difficult things about XSLT. I think of it as a lookup
table for elements based on what you enter for the
<strong>match</strong> and <strong>use</strong> attributes.</p>
<p>In the code I provided, that first loop is basically looping
over the unique values of the <strong>type</strong> dynamic
metadata fields (this is what the XPath that uses the
<code>key()</code> method is doing). Since we are looping over the
unique values, we can sort on those values as well as filter
elements within the XML based on the current value.</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/350214392014-10-22T20:12:29Z2014-10-22T20:12:29ZHide headings if no matching links<div><p>Great, thanks again for all your help.</p></div>rgraves2tag:help-archives.hannonhill.com,2010-02-09:Comment/350214392014-10-23T11:54:11Z2014-10-23T11:54:11ZHide headings if no matching links<div><p>Not a problem at all, Robert. 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 Griffith