Alphabetized list: looking for best practise

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Alphabetized list: looking for best practise

CoMedia
All,

I'm preparing a mobile web app as a side project for a charity. Everything is running smoothly, except one thing: I'm struggling with alphabetized lists. They need to look like this:

<li class="group">B</li>
<li><a href="#Beatles">Beatles</a></li>
<li><a href="#BelleSebastian">Belle & Sebastian</a></li>
<li class="group">C</li>
<li><a href="#CrowdedHouse">Crowded House</a></li>
<li class="group">J</li>
<li><a href="#JennyLewis">Jenny Lewis</a></li>
<li><a href="#JohnMayer">John Mayer</a></li>
<li class="group">Z</li>
<li><a href="#Zero7">Zero 7</a></li>

So the question is: what is the best practise to create such a list? I guess the best way to do this is using arrays or maps, but how do I avoid many database calls? Has anybody done this before? I'd like to hear from you!

CoMedia,
Alfred Konijnenbelt


____________________________________________________________________________

CoMedia [web & data concepts]            Bakemastraat 2, 3822 WJ  Amersfoort
[i] http://comedia.nl     [e] [hidden email]    [r] http://comedia.nl/route
[t] +31 (0)33 455 84 26   [f] +31 (0)33 455 09 38    [m] +31 (0)628 82 01 22
       


#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Alphabetized list: looking for best practise

Tami Williams
1. the code below assumes you do a named inline search called 'getProviders', then use that named inline.

2. then, for your display

[local('temp') = '']
[records(-inlinename='getProviders')]
<br>[if(#temp!= field('provider_name')->Get(1))]<a href="[$XFA_ProvidersV2]&ltr=[field('provider_name')->Get(1)]">[string_uppercase(field('provider_name')->Get(1))]</a> <br>
[/if]
[#temp = field('provider_name')->Get(1)]
<b>[field('provider_name')]</b>
[/records]


3. you could also do something like this:
http://wia.chapinhall.org/site.lasso?r=1548589&fuseaction=search.providers



On Jan 5, 2012, at 4:22 PM, Alfred Konijnenbelt wrote:

> All,
>
> I'm preparing a mobile web app as a side project for a charity. Everything is running smoothly, except one thing: I'm struggling with alphabetized lists. They need to look like this:
>
> <li class="group">B</li>
> <li><a href="#Beatles">Beatles</a></li>
> <li><a href="#BelleSebastian">Belle & Sebastian</a></li>
> <li class="group">C</li>
> <li><a href="#CrowdedHouse">Crowded House</a></li>
> <li class="group">J</li>
> <li><a href="#JennyLewis">Jenny Lewis</a></li>
> <li><a href="#JohnMayer">John Mayer</a></li>
> <li class="group">Z</li>
> <li><a href="#Zero7">Zero 7</a></li>
>
> So the question is: what is the best practise to create such a list? I guess the best way to do this is using arrays or maps, but how do I avoid many database calls? Has anybody done this before? I'd like to hear from you!
>
> CoMedia,
> Alfred Konijnenbelt
>
>
> ____________________________________________________________________________
>
> CoMedia [web & data concepts]            Bakemastraat 2, 3822 WJ  Amersfoort
> [i] http://comedia.nl     [e] [hidden email]    [r] http://comedia.nl/route
> [t] +31 (0)33 455 84 26   [f] +31 (0)33 455 09 38    [m] +31 (0)628 82 01 22
>
>
>
> #############################################################
> This message is sent to you because you are subscribed to
>  the mailing list Lasso
> [hidden email]
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>

#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Alphabetized list: looking for best practise

stevepiercy
In reply to this post by CoMedia
I do that for this, but I use years to group things:
http://www.peoplepowersc.org/news/?-page=7

Here's how I would do it for your HTML:

     inline;
         local('alpha' = string);
         records;
             if(#alpha != string_extract(field('group'),-startposition=1,-endposition=1));
                 #alpha = string_extract(field('group'),-startposition=1,-endposition=1);
                 '<li class="group">' + #alpha + '</li>';
             /if;
             '<li><a href="#' + string_replace(field('group'),
-find=' ', -replace='') + '">' + field('group') + '</a></li>';
         /records;
     /inline;

--steve


On 1/5/12 at 10:22 PM, [hidden email] (Alfred Konijnenbelt) pronounced:

>All,
>
>I'm preparing a mobile web app as a side project for a charity.
>Everything is running smoothly, except one thing: I'm
>struggling with alphabetized lists. They need to look like this:
>
><li class="group">B</li>
><li><a href="#Beatles">Beatles</a></li>
><li><a href="#BelleSebastian">Belle & Sebastian</a></li>
><li class="group">C</li>
><li><a href="#CrowdedHouse">Crowded House</a></li>
><li class="group">J</li>
><li><a href="#JennyLewis">Jenny Lewis</a></li>
><li><a href="#JohnMayer">John Mayer</a></li>
><li class="group">Z</li>
><li><a href="#Zero7">Zero 7</a></li>
>
>So the question is: what is the best practise to create such a
>list? I guess the best way to do this is using arrays or maps,
>but how do I avoid many database calls? Has anybody done this
>before? I'd like to hear from you!
>
>CoMedia,
>Alfred Konijnenbelt
>
>
>____________________________________________________________________________
>
>CoMedia [web & data concepts]            Bakemastraat 2, 3822 WJ  Amersfoort
>[i] http://comedia.nl     [e] [hidden email]    [r] http://comedia.nl/route
>[t] +31 (0)33 455 84 26   [f] +31 (0)33 455 09 38    [m] +31 (0)628 82 01 22
>
>
>
>#############################################################
>This message is sent to you because you are subscribed to
>the mailing list Lasso
>[hidden email]
>To unsubscribe, E-mail to: <[hidden email]>
>Send administrative queries to  <[hidden email]>

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- --
Steve Piercy               Web Site Builder              
Soquel, CA
<[hidden email]>                  <http://www.StevePiercy.com/>

#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Alphabetized list: looking for best practise

CoMedia
In reply to this post by CoMedia
Tami, Steve,

Thank you for the solutions you suggested. They both work fine. Steve's solution is very close to what I came up myself, so I'll go with his suggestion. Thanks again!

CoMedia,
Alfred Konijnenbelt


____________________________________________________________________________

CoMedia [web & data concepts]            Bakemastraat 2, 3822 WJ  Amersfoort
[i] http://comedia.nl     [e] [hidden email]    [r] http://comedia.nl/route
[t] +31 (0)33 455 84 26   [f] +31 (0)33 455 09 38    [m] +31 (0)628 82 01 22
       


#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>