By robertem on
Hi everybody,
I'm trying to determine the best method to create a 3 column list of vocabulary terms similar to what you would find at most directory based sites.
I'm doing a site with localized content and need to display a list of US states (the terms), that would link to a page containing a list of teaser nodes.
I've created the teaser pages using views and have tried the Views bonus pack (3 column by term) to create the directory layout but have not had any success.
Thanks for any advice,
Rob
Comments
Let me do some small changes
Let me do some small changes to my usual vocabulary list code. This is not difficult; it just takes a bit of additional CSS. I don't see any need for Views in any of what you're asking. A teaser list is normal "taxonomy/term/xxx" presentation.
Nancy W.
Drupal Cookbook (for New Drupallers)
Adding Hidden Design or How To notes in your database
NancyDru
That would be great
Thanks Nancy, I would appreciate any help you could give.
Rob
Try this
Put this code in a php-format page.
Then include this in your CSS:
This is untested, but should work.
Nancy W.
Drupal Cookbook (for New Drupallers)
Adding Hidden Design or How To notes in your database
NancyDru
This worked perfectly,
This worked perfectly, thanks so much!
Rob
Views will work
You cane use the view bonus with panles.module or more custom...
A new function for the view grid module. A three column grid_view put after the normal function theme_views_bonus_view_grid a new one.
//16.5.07 Grid View Taxonomy-Terms will sort everything by taxonomy terms and print them sorted by term.
function theme_views_bonus_view_grid_ext($view, $nodes, $type) {
drupal_add_css(drupal_get_path('module', 'views_bonus') .'/views_bonus.css');
$fields = _views_get_fields();
$content = '
$count = 0;
$total = count($nodes);
$myterm_prev = "";
foreach ($nodes as $node) {
if (isset ($node->term_data_name)){
$myterm = $node->term_data_name;
} else {
$myterm = t('No term');
}
//
$item = '';
if ($count == 0) {
$content .= '
} elseif ($count % 3 == 0 || $myterm != $myterm_prev) {
if ($myterm != $myterm_prev) {
$content .= '
} $content .= '
}
foreach ($view->field as $field) {
if ($fields[$field['id']]['visible'] !== FALSE) {
if ($field['label']) {
$item .= "
";
}
$item .= "
";
}
}
$content .= "
\n";
$count++;
//if ($count % 4 == 0 || $count == $total) {
if ($count == $total) {
$content .= '
';
}
$myterm_prev = $myterm;
}
$content .= '
';
if ($content) {
return $content;
}
}
Than put this in code:
$items['bonus_grid_ext'] = array(
'name' => t('Bonus: 3 Colum Grid View by taxonomy term'),
'theme' => 'views_bonus_view_grid_ext',
'validate' => 'views_ui_plugin_validate_list',
'needs_fields' => true,
);
the function views_bonus_views_style_plugins
Now you can chose your new view in the views Module
Dirk
Thanks Dirk, I'll give this
Thanks Dirk, I'll give this a try as well. Always good to have options!
Rob
It looks as though I may
It looks as though I may have to go with Views after all as I will need to have some control over the sort order on the summary pages.
I'm having a few issues with your code however.
Should this line $content = 'name . '">'; be $content = '"'.name . '">'; ?
Also, what configuration should I be using in Views?
I was trying different options using "Taxonomy: Vocabulary Name".
Thanks again,
Rob
Trying to understand
Hi Robertem,
I´m trying to understand, its hard not to see what you need.
1. Your Vocbulary is USA.
2. Your terms are 51 States right?
Ok lets start.
1. First generate a new View as Page with a URL, Title etc..
2. Chose the new grid View I gave to you.
3. Chose the fields you want to display in your View. First I would take Node Title with the option "as link".
(that will bring you to the node)
4. Chose your Filter it should be Taxonomy Vocabulary (USA) and the option "one of" (all 51 States)
So i hope this will help you.
Anyway just contact me or give me access to a testing page where I can have a look.
Dirk
Thanks Dirk, That's what I
Thanks Dirk,
That's what I was thinking regarding views, just wanted to be sure I understood.
I'm getting a syntax error in the code you gave me on this line;
$content = 'name . '">';
in the original grid bonus the line is
$content = '
should it be
$content = 'name . '">';
Thanks,
Rob
I think I see the problem
Could you repost your code inside a code tag? some of the html is getting striped out
This
is coming out as
$content = 'name . '">';
in the original grid bonus the line is
$content = '
should it be
$content = 'name . '">';
Thanks,
Rob
Cop< and paste....
Hi Rob,
its working now? I think it´s a copy and paste problem. Still any questions?
Dirk
Hey Dirk, Still the same
Hey Dirk,
Still the same issue, you just have to surround the whole block of code with code tags (see below under "allowed html tags") so the Drupal forum won't strip the tags out.
Thanks again
allowed html tags ?
Lets see if we understand right,
First just have a look here http://www.freelens.ws/dirksway/user/1/galerie or here for three collums http://www.freelens.ws/dirksway/user/16/galerie
Its a testing side but you can see the new grid view in action. You want change the general layout for a taxonomy vocabulary? Or a different Style of a View (MYSQL-list)? Any testing site for me to see?
Or something like the front page of the actual page we are doing? www.freelens.ws/dirksway
Here Im using views as well ........
But anyway if you tell me an email e send you the new views_bonus.module
Cheers Dirk
Unclear, help!
If I understand you correctly, you're saying to paste the code which begins...
"//16.5.07 Grid View Taxonomy-Terms will sort everything by taxonomy terms and print them sorted by term.
function theme_views_bonus_view_grid_ext($view, $nodes, $type) {
drupal_add_css(drupal_get_path('module', 'views_bonus') .'/views_bonus.css');"
anywhere in the "views_bonus_grid.module"....
I've done that.
But then you write, "Then you put this in code..."
$items['bonus_grid_ext'] = array(
'name' => t('Bonus: 3 Colum Grid View by taxonomy term'),
'theme' => 'views_bonus_view_grid_ext',
'validate' => 'views_ui_plugin_validate_list',
'needs_fields' => true,
);
I have no idea how to use this final code snippet. Where do I paste it? Into which module or file? What does "put it in code" mean? Please help...
Many Thanks!
Views Module with new grid sorted by term
Hi ctman,
wich version of the view_bonus_module are you using? I will send you the module with the new function if you send me an email!
Dirk