In the template for the Glossary page I have an xslt that list the terms alphabetically. However I want a alpabet list 'menu' that when the letter is clicked it will jump down to the first word that starts with that letter. Any letter in this menu that is not used in the Glossary should be present but not a link eg
using the small list above I'd like to see where [x] means a link'd letter
[A][B][C] D [E] F [G] H I ....Z
However I have no idea how to accomplish this in XSLT. I did serch the forums but the terms dictioanry and glossary don't yeild results that macth this sort of usage. Any help/guidance would be apreciated.
Just getting back to look at this now. Thanks very much for your reply, I can kind of follow the logic however my knowledge on templates is very weak - so this should be a good learning experience for me. Unfortunatley a copy and paste of the code above give me an immediate error.
Error occured
System.FormatException: String must be exactly one character long. at System.Convert.ToChar(String value, IFormatProvider provider) at umbraco.library.Split(String StringToSplit, String Separator)
I was able to solve this by adding a space in the split command.
Then it all seems to run OK - except that the alpha menu at the top is not built.
I'm guessing the split fails to 'do anything' with the space and therefor no matches are made on a
letter-by-letter basis and I just get the whole unsplit array spat back out rather then matched links..
Aslo - this makes the required solution more complicated ... this works for my sample list above - but what happens if multiple glossary items start with the same letter eg.
A link to the definition won't work will it? I'll need another template strucutre to insert letter links in the defintiion list
A -- Apple ... definition -- Apricot ... definition B -- Bannanas ... definition C -- Cherries ... definition -- Cucumbers ... definition E -- Eggplant ... definition
I'm going to look futher into the split command for just to get the linking in the alpha menu to work and then see how that effect the terms that share the same letter. I'll post any updates I do have.
Ha .. 30sec more thought and I could have saved a whole lot of typing .. I added spaces to the inital list to split by. umbraco.library:Split('A B C D E F G H I J K L M N O P Q R S T U V W X Y Z', ' ')
The resultant list then links to the first definition item for each letter - perfect.
The only thing this doesn't do that I could possibly want is the Alphabet breaks in the content list (as shown above). And an "other" matched area for things like non-alpha values eg numeric [0..9 $ %]
My bad about the character - I was actually using the tokenize() function in exslt.org (I develop on a Mac, so...) which accepts an empty character as the tokenizer - was pretty sure the Split() method worked the same way.
For the Alphabet headers, you could just use the $letters//value nodes again - applying templates to each of them, rendering a header with the letter, and then applying templates to all the GlossaryTerm nodes that starts with that letter.
For the "others" section, look for nodes which doesn't have a 1st 'letter' contained in the "alphabet" - something like:
Create alphbetical menu based on child nodes.
I have created a 'glossary' Doc Type to hold a group of 'Glossary Term' child nodes.
Glossary
-- Apples
-- Bannanas
-- Cherries
-- Eggplant
-- Grapes
In the template for the Glossary page I have an xslt that list the terms alphabetically. However I want a alpabet list 'menu' that when the letter is clicked it will jump down to the first word that starts with that letter. Any letter in this menu that is not used in the Glossary should be present but not a link eg
using the small list above I'd like to see where [x] means a link'd letter
[A][B][C] D [E] F [G] H I ....Z
However I have no idea how to accomplish this in XSLT. I did serch the forums but the terms dictioanry and glossary don't yeild results that macth this sort of usage. Any help/guidance would be apreciated.
Hi Jamie,
Here's something to get you started:
/Chriztian
Just getting back to look at this now.
Thanks very much for your reply, I can kind of follow the logic however my knowledge on templates is very weak - so this should be a good learning experience for me. Unfortunatley a copy and paste of the code above give me an immediate error.
Error occured
System.FormatException: String must be exactly one character long.
at System.Convert.ToChar(String value, IFormatProvider provider)
at umbraco.library.Split(String StringToSplit, String Separator)
I was able to solve this by adding a space in the split command.
<xsl:variable name="letters" select="umbraco.library:Split('ABCDEFGHIJKLMNOPQRSTUVWXYZ', ' ')" />
Then it all seems to run OK - except that the alpha menu at the top is not built.
I'm guessing the split fails to 'do anything' with the space and therefor no matches are made on a
letter-by-letter basis and I just get the whole unsplit array spat back out rather then matched links..
Aslo - this makes the required solution more complicated ... this works for my sample list above
- but what happens if multiple glossary items start with the same letter eg.
-- Apple
-- Apricot
-- Bannanas
-- Cherries
-- Cucumbers
-- Eggplant
A link to the definition won't work will it? I'll need another template strucutre to insert letter links in the defintiion list
A
-- Apple ... definition
-- Apricot ... definition
B
-- Bannanas ... definition
C
-- Cherries ... definition
-- Cucumbers ... definition
E
-- Eggplant ... definition
I'm going to look futher into the split command for just to get the linking in the alpha menu to work and then see how that effect the terms that share the same letter. I'll post any updates I do have.
Ha .. 30sec more thought and I could have saved a whole lot of typing .. I added spaces to the inital list to split by.
umbraco.library:Split('A B C D E F G H I J K L M N O P Q R S T U V W X Y Z', ' ')
The resultant list then links to the first definition item for each letter - perfect.
The only thing this doesn't do that I could possibly want is the Alphabet breaks in the content list (as shown above). And an "other" matched area for things like non-alpha values eg numeric [0..9 $ %]
Hi Jamie,
My bad about the character - I was actually using the tokenize() function in exslt.org (I develop on a Mac, so...) which accepts an empty character as the tokenizer - was pretty sure the Split() method worked the same way.
For the Alphabet headers, you could just use the $letters//value nodes again - applying templates to each of them, rendering a header with the letter, and then applying templates to all the GlossaryTerm nodes that starts with that letter.
For the "others" section, look for nodes which doesn't have a 1st 'letter' contained in the "alphabet" - something like:
Let me know how you get along,
/Chriztian
is working on a reply...