Hi!

I have created a table in a View that display a list of companies sorted alphabetically. My companies are stored as a CCK type that I have set up with some special fields.

I would like to extend my listings to include an linked alphabet on top of the listing pages. If one click the link a in the alphabet I want to display companies with a name starting with a. If one clicks b - display only companies with a name starting with a b etc.. Check this image for a sketch of what I want to do: http://olalindberg.com/forumContents/drupal/071022_SketchForCompanyListi...

I tried to use this guide: http://drupal.org/node/74715 but I can't get it to work. I don't understand whats meant with this paragraph:

To accomplish this, I first created a view called 'sitemap' with an url of 'sitemap', a title of 'Site Map', and a page display set to display as a list, used the node title as a field, and set it up to display 30 items to be sure it could at least display the whole alphabet on one page. I gave it a taxonomy argument with an option of '1' (meaning group it by the first letter of the term) and set it up to display all results, sorted ascending. I then created a second taxonomy term argument, everything the same as the first one, but with the option field left blank, meaning that it should group the nodes that matched the first argument by the complete taxonomy term name.

Thanks in advance!

Comments

wmostrey’s picture

Did you try the Views Alpha Pager module? I think it fits your needs.

olalindberg’s picture

That module did exactly what I needed. I had installed this module before (from some recommendations) but hadn't gotten it to work.

Here is what I did to get it working:

  1. Create a new view
  2. Basic Information: Set the name for the view
    • Page:
    • Provide a page and set the URL
    • In the pager drop down select alpha
    • Select 29 nodes per page
  3. Fields: Add the fields you would like to display in your listing. I.e. the name of your nodes
  4. Filter: Add a filter for your search to limit from getting all nodes
  5. Sort Criteria: I haven't added any sort criteria but I guess thats fine as well.

Thanks a lot!

edg’s picture

I had the argument working before but when i upgraded all my modules and to Drupal 5.7 it broke. Added the Alpha mod, removed the existing argument, and that was it to get it working. I like the facility for filtering common words like A, the, and An, etc.

www.iofilm.co.uk - Not a Drupal site yet!

asugene’s picture

Very helpful in making Drupal at like a wiki. Thanks.

rhinokitty’s picture

Very helpful, thanks!

EllECTRONC’s picture

Views Alpha Pager perfectly works!
Sort Criteria: It is obligatory attribute for Views Alpha Pager!
Not important how many node in page. Also it is not important Fields and Filter. The main thing to specify criterion of sorting. For example: Node Title!
What a pity, does not work with the Russian alphabet!

It's hard to understand the one who is keep silence!

JubW’s picture

We need this updated to version 6

ikarusweb’s picture

subscribe - need a D6 version

EllECTRONC’s picture

For D6 you may use views2 or glossary modules

pelicani’s picture

maybe I'm missing steps or doing it wrong, but the glossary solution built into views 2 has some issues.
until they get it resolved, or I spend more time figuring it out, I'd recommend following this method ... http://tedserbinski.com/tags/drupal/creating-alpha-pager-with-views-2-an...

Good stuff.

for example, here is my PHP for the header ...

$options = array("attributes"=>array("class"=>"alpha-page"));
foreach(range('A','Z') as $letter) {
  print l($letter, "directory/".$letter,$options);
}

Technical Architect : Philadelphia, PA

cybermache’s picture

Thanks for your code. I added a little bit to it to allow me to theme the active letter. There's probably another way to do this but for now this works pretty well. The only thing I couldn't figure out was how to get an array of the title result of the view to allow me to unlink the letters that don't link to anything. Hence the if statement on the 'x' letter. What I wanted was some sort of isset() check on the array created from a list of nodes limited to and grouped by their first character. But just couldn't make it work with what was available in views.

<?php
  $output .= '<div class="alpha-pager">';
  $path = arg(2); // gets the letter from the URL
  $args = %1; // gets the title letter being created by your views argument 
  $list = array();
  foreach(range('a','z') as $letter) {
    if ($path == $letter) { // compares the two letters and makes active if TRUE
      $options = array("attributes"=>array("class"=>"alpha-page active"));
    }
    else { //output inactive value
      $options = array("attributes"=>array("class"=>"alpha-page"));
    }
  }  
  foreach(range('a','z') as $letter) {
    if ($letter == 'x') { // which ever letter that doesn't have titles || for more
      $list[] = $letter;
    }
    else { // output linked letter
      $list[] .= l(strtoupper($letter), "directory/". $letter,$options); 
    }
  }
  $output .= implode(" - ", $list); //separate by spaces and hyphen 
  $output .= "</div>";
  print $output;

?>
stuchl4n3k’s picture

For anyone interested I have a working solution for Drupal 6 and views described at my blog post.