Home | Products | Consulting | Forums | Support | Order | 1-800-752-0455
  Main
Index
Search
Posts
Who's
Online
Log
In

Home: Products: Listings Manager Add-ons:
List Homepage index with alpha letters

 

 


cclinton
User

Apr 14, 2006, 9:52 AM

Post #1 of 5 (5324 views)
Shortcut
List Homepage index with alpha letters Can't Post

I posted this in the regular Listing Manager forum before realizing this would technically be an add on or modification and thus should be over in this forum:

Has anyone successfully added sort letters to the homepage index? I would like to provide my viewers the ability to quickly jump to the people who's names start with L or R or some other letter without having to generate separate pages. Here's an example of what I am trying to do:
http://www.buyusa1.com/find_agent.php
I am assuming I can set this up similar to the image, no image blocks but am afraid that I will have to generate a separate search script and search page to make this happen for every letter. In other words I am afraid that I will have to set my page up like this:
<form method=post action="http://www.mydomain.com/templates/_realty/searcha.php">
<!-- template insert : $hidden_fields$ -->
<!-- template insert : $list$ -->
<p>A</p>
<!-- templatecell : row_image -->
***code for user block***
<!-- /templatecell : row_image -->
<!-- templatecell : row_noimage -->
***code for user block***
<!-- /templatecell : row_noimage -->
<form method=post action="http://www.mydomain.com/templates/_realty/searchb.php">
<!-- template insert : $hidden_fields$ -->
<!-- template insert : $list$ -->
<p>B</p>
<!-- templatecell : row_image -->
***code for user block***
<!-- /templatecell : row_image -->
<!-- templatecell : row_noimage -->
***code for user block***
<!-- /templatecell : row_noimage -->
etc.

This looks like a lot of work to code this page, code the homepage search pages, and code the separate cgi pages. Anyone know of a shortcut?


MikeB
Staff / Moderator


Apr 15, 2006, 3:26 PM

Post #2 of 5 (5289 views)
Shortcut
Re: [cclinton] List Homepage index with alpha letters [In reply to] Can't Post

Hi cclinton,

Thanks for the post! Smile

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:


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"):


Code
  <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! Smile

Cheers,
Mike Briggs - Product Specialist
support@interactivetools.com


Hire me!
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 Priority Consulting.


cclinton
User

Apr 17, 2006, 9:21 AM

Post #3 of 5 (5243 views)
Shortcut
Re: [MikeB] List Homepage index with alpha letters [In reply to] Can't Post

That works perfectly.

I did modify the output script a little to insure the letter fit into my css classes, to generate a return to top link and to space them out a little. Here's the new script:

<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('<br><div class=headings2>');
document.write('<a name=' + letters[count] + '>' + letters[count] + '</a>');
document.write('</div>');
document.write('<div class="headings2" align=right>');
document.write('<a href=#> Back to Top </a>');
document.write('</div>');
document.write('<br>');
output[count]="Yes"
}
}
</script>

I will add a link to the site in a couple days when it goes live. It's currently in a test domain and the link would die when I go live. I don't want to frustrate readers of this forum when they click on a link to see the sample and get a dead link.

A couple quick questions: do you think this will work in conjunction with the 2 column add-on script? Also, can you think of any browsers that might have difficulty reading or implimenting this script?


ross
Staff / Moderator


Apr 17, 2006, 3:30 PM

Post #4 of 5 (5237 views)
Shortcut
Re: [cclinton] List Homepage index with alpha letters [In reply to] Can't Post

Hi.

To be honest, I am really not a JavaScript guru so this is going above my level of expertise. My best suggestion is going to be to just give it a shot Smile.

Of course, if anyone else had a suggestion or some tips, it would be great to hear from you Smile.
-----------------------------------------------------------
Cheers,
Ross Fairbairn - Product Specialist
support@interactivetools.com


Hire me!
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 Priority Consulting.




cclinton
User

May 5, 2006, 11:31 AM

Post #5 of 5 (5046 views)
Shortcut
Re: [MikeB] List Homepage index with alpha letters [In reply to] Can't Post

Here's the page up and running:

http://www.buyusa1.com/listman/homepages/

 
 
 


Search for (options)
Products
CMS Builder
Article Manager
Realty Manager
Listings Manager
Order Now
Services
Priority Consulting
Support
Online Documentation
Support Forums
Support Homepage
Company Info
12 reasons to choose us!
Meet the team
Monthly newsletter
Contact Us
Toll Free: 1-800-752-0455
Phone: (604) 689-3347
Sales | Support
Conditions of Use | Privacy Policy | Copyright © interactivetools.com 2008
#201 - 2730 Commercial Drive, Vancouver BC Canada V5N 5P4