
MikeB
Staff
/ Moderator

Apr 15, 2006, 3:26 PM
Post #2 of 5
(6922 views)
Shortcut
|
|
Re: [cclinton] List Homepage index with alpha letters
[In reply to]
|
Can't Post
|
|
Hi cclinton, Thanks for the post! I've taken a look at this for you and while I think I've found a way to set up something like this it will work a bit differently than what you've mentioned. Essentially the method I've come up with will use a bit of JavaScript so when it's outputting it's users (which it does by default in alphabetical order) it will check to see if this is the first agent that starts with this letter. For example, when the script gets to "Bob Smith" it checks to see if any users with the first letter "B" have been output yet, if not then it will output a letter B and then output the name "Bob Smith". Then, when it gets to "Brian Williams" it will see that the letter "B" has already been output and will just output this name. As far as I can tell this will work very similarly to the page you've linked to. I'd like to do a bit more testing on this but if you'd like to test it out on your site in the meantime I'll outline how you can get started: 1. You'll want to open up your _publish_homepage_index.html template file and somewhere between the <head> and </head> tags you'll add this bit of code:
<script> var output=new Array("No","No","No","No","No","No","No","No","No","No","No","No","No","No","No","No","No","No","No","No","No","No","No","No","No") var letters=new Array("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") </script> This just defines some arrays for the alphabet and for us to know if this value has been output yet. 2. Next, you'll just put this code in the templatecells for user_image and user_noimage. You'll want to put them right after the opening line of the templatecell so they'll be the first thing looked at (this way "B" will be output before any of the names that start with the letter "B"):
<script> var1 = "$user_name$" var2 = var1.substr(0, 1) for (count = 0; count <= 25; count++) { if(letters[count]==var2.toUpperCase() && output[count]=='No') { document.write('<a name=' + letters[count] + '>' + letters[count] + '</a><BR>'); output[count]="Yes" } } </script> 3. The last thing you'll want to do is output the links at the top of the page that will link to these different letters using this format: <a href="#A">A</a> <a href="#B">B</a> <a href="#C">C</a> . . . <a href="#Y">Y</a> <a href="#Z">Z</a> Notes: First, you'll want to ensure that the page this _publish_homepage_index.html template is creating (/listman/homepages/index.html) is already being sorted alphabetically by the name of your agents. Also, currently the script won't output a letter if no user has a name starting with that letter. For example, even if there are no agents with a first name starting with "C" there will still be a link at the top of the page that says "C" (because you're adding this manually in step 3) but the link will just refresh the page. Give this a try and let me know what you think. Also, I'd love to see an example of this up and running on your site once you've set this up. I hope this helps! Cheers, Mike Briggs - Product Specialist support@interactivetools.com [hr][i][url "http://www.interactivetools.com/consulting/"][b]Hire me![/b][/url] Save time by getting our experts to help with your project. Template changes, advanced features, full integration, whatever you need. Whether you need one hour or fifty, get it done fast with [url "http://www.interactivetools.com/consulting/"][b]Priority Consulting[/b][/url].[/i]
|