Hello everyone,
I'd like to request some support or advice from the more knowledgeable members of the community regarding an issue with Views 2.
I am trying to build a glossary view to show all the content to the user alphabetically. I started from the default "glossary" view as my starting point, but I have two issues I am unsure how to handle.
First, I would like to output all letters, even those that have no associated content. Instead of:
B (1) | D (1) | F (2) etc.
I would like:
A (0) | B (1) | C (0) | D (1) etc., with only those letters that have associated nodes working as links.
I am not sure whether this functionality is best handled within the view itself, or in a theming template. Advice please?
Second issue. My nodes are titled both in greek and in english. I would like to show each alphabet individually on its own line, something like:
A (0) | B (1) | C (0) | D (1) ...
A (0) | B (0) | Γ (3) | Δ (2) ...
I tried to use a filter to restrict the node titles, but there is no option "starts with one of" [abcdefghijkl...] - any other clever workarounds?
Thanks in advance for your time and any replies!
Comments
Can any one answer atleast
Can any one answer atleast the first part of the problem..?
------------
Volvo, Video, Velcro. (I came, I saw, I stuck around.)
my solution
I had almost forgotten about this :)
There sure are better ways of doing this, but I finally ended up theming it in by hand in my view's tpl.php file.
that is the relevant bit of code, in case anyone else has a similar need.
Feel free to suggest better ways of course :)
hi, I'm trying to implement
hi, I'm trying to implement you solution but i cannot get to work it right. All the letters appears but no links to it. I've tried to put on the display and on the style output .tpl.php and neither one worked. For wath I understand the $rows on the display output is already html so i cannot get the variables link nor url. And on the style, it completly ignores and shows the default output. Any suggestions?
Thanks in advance
replace what's in
replace what's in views-view-summary-unformatted.tpl with the code above...thanks for the code btw.
_
Also see http://drupal.org/node/403012.
Need advise
Hi all,
Am also facing same problem. I configured glossary correctly, it displays good what i expected.
but i need to display the pager like all the alphabets without any missing character
Now it looks like this
B | C | F | J | N | P | S | V
But I need like this
A | B | C | D | E | F | G | H | I | J .. etc
Thanks
Here's an updated template file
Here's an updated version of Silth's Views 2 template code to Views three and got rid of the Undefined Index error you get when there aren't a full alphabet's worth of nodes on display.
chak_boss, you're most of the way there.
What you need to do now is add a template file in your theme folder. Assuming you're using the default layout for this (the tab called "attachment" in your glossary view should be using "Format: Unformatted list"), this is what you wanna do:
1) Copy the file at: sites/modules/views/templates/views-views-summary-unformatted.tpl.php into your theme folder's templates folders (sites/themes/YOUR-THEME/templates).
2) Replace the content of that file with this code:
And that should sort it.
Small tweak to maintain link "active" class
The code above worked very well for me. I added a small bit to reinstate the link class so that you can style the "active" state:
echo '<a href="'. $rows[$counter]->url. '" class="'. $row_classes[$counter] .'"><span class="letter">'. $rows[$counter]->link .'</span>' . '</a>';Drupal 7 solution
Hello,
I know this is old, but we just had a client ask for this on a Glossary of terms we made, etc.
Anywho, I did this through a preprocess in the template.php. It is frowned upon in the best practices circles to add functional php in a tpl, etc.
Anywho, here it is (not the most elegant solution, but it workz):
John Ouellet
Sales Engineering Manager
https://thinktandem.io/
How switch on ajax this code?
But how switch on ajax this code? Standart metod with "enabled ajax" in views not working. Thanks
How order last name from title
How order last name from title ?
Drupal 8 twig template
Here is a version I use in Twig, it has a little modification to be used with anchors:
How order last name from
How order last name from title ?
Last Name Sorting
Name Field Works pretty well now in 8
works pretty what? Order last
works pretty what? Order last name from title?
Small tweak
I had to alter line 11:
% if (counter < max and rows[counter].link == letter|upper) %}otherwise the condition was never true.
Thank you, @e.ruiter. You
Thank you, @e.ruiter. You saved my time.
Visit my blog for more info: Make Drupal Easy.
Here is working with D9/D10
Here is working with D9/D10 solution for glossary attachment template: