Posted by kmonty on November 6, 2009 at 6:01pm
| Project: | Node Gallery |
| Version: | 6.x-2.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | critical |
| Assigned: | DesignWork |
| Status: | closed (won't fix) |
Issue Summary
Description says it all. Tested with latest dev and alpha10
If you use these fields, your view returns no results period:
- Node Gallery Image: Cover View
- Node Gallery Image: Image Image
- Node Gallery Image: Image weight Image weight
If you use these fields, your view returns incorrect results:
- Node Gallery: Image Count Image Count (returns the first result only, repeats it)
- Node Gallery: Gallery ID Gallery ID (returns the first result, repeats it, returns cover image rather than GID)
- Node Gallery: Gallery Operations Gallery Operations (first result repeating)
Comments
#1
the same in alpha11!
Critical.
#2
I will have a look.
#3
Hi justintime,
I changed the function pre_render(&$values) in the node_gallery_handler_field_gid.inc. For me I can work with it without any problem. No broken views any more with views 2.
Here comes my function:
function pre_render(&$values) {foreach ($values as $value) {
//$fids[$this->field_alias] = $value->{$value->{$this->aliases[$this->additional_fields['fid']]}};
//$gids[] = $value->{$this->field_alias};
$gids = $value->node_galleries_gallery_gid;
}
if (!empty($gids)) {
$result = db_query("SELECT n.nid, ng.*, f.filepath, n.title FROM {node} n INNER JOIN {node_galleries} ng ON
n.nid = ng.gid INNER JOIN {files} f ON ng.fid = f.fid
WHERE ng.gid = %d", $gids);
while ($r = db_fetch_array($result)) {
$items[$gids] = $r;
}
// If nga is active, then fetch the access type and password from the db and merge it for use later in render()
if (module_exists('node_gallery_access')) {
$nids = array_keys($items);
$result = db_query("SELECT n.uid, n.nid, nga.access_type, nga.password FROM {node} n INNER JOIN {node_gallery_access} nga ON n.nid = nga.nid WHERE n.nid IN (". db_placeholders($nids) .")", $nids);
while ($r = db_fetch_array($result)) {
$items[$r['nid']] = array_merge((array)$items[$r['nid']], $r);
}
}
foreach ($values as $value) {
$new = array_merge((array)$value, $items[$value->{$this->field_alias}]);
$new_items[] = (object)$new;
}
$values = $new_items;
}
}
Can some one please test it?
Cheers
Dirk
#4
Can someone export a view, or can one of the OP's verify this fix works? I never had a problem, so I'm not a good tester, plus I'm busy setting up some CI goodness for NG*.
@DesignWork, the code looks pretty sound, save for two things.
#5
Hi justintime,
What means "looks pretty sound"? But anyway I was not ready testing everything (node_gallery_access).
I had no Problem with views as well so I crated one. I made all my images is_cover = 0 in the database. So the sql statement will give me an an empty result. And than I got a lot of problems with the view_handlers.
As I know there is no need to have a "cover" in node_gallery. So I thought we just ingnore it and just turn back any Image. But to be honest we should if there is a cover return it and if not return any image.
No it is there just make a print_r($value). Views magic!
#6
Hi justintime,
I made a view with two gallery types (Gallery and Photo Gallery) as Fliter. This breaks any view as well.
here comes the view.
$view = new view;$view->name = 'gallery_page';
$view->description = 'gallery_page';
$view->tag = 'gallery_page';
$view->view_php = '';
$view->base_table = 'node';
$view->is_cacheable = FALSE;
$view->api_version = 2;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->override_option('fields', array(
'gid' => array(
'label' => '',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'strip_tags' => 0,
'html' => 0,
),
'empty' => '',
'hide_empty' => 0,
'empty_zero' => 0,
'link_to_node' => 1,
'node_gallery_setting' => 'node_gallery_gallery',
'exclude' => 0,
'id' => 'gid',
'table' => 'node_galleries_gallery',
'field' => 'gid',
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
),
'title' => array(
'label' => '',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'strip_tags' => 0,
'html' => 0,
),
'link_to_node' => 1,
'exclude' => 0,
'id' => 'title',
'table' => 'node',
'field' => 'title',
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
),
'body' => array(
'label' => '',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'strip_tags' => 0,
'html' => 0,
),
'exclude' => 0,
'id' => 'body',
'table' => 'node_revisions',
'field' => 'body',
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
),
'image_count' => array(
'label' => '',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'strip_tags' => 0,
'html' => 0,
),
'empty' => '',
'hide_empty' => 0,
'empty_zero' => 0,
'set_precision' => FALSE,
'precision' => 0,
'decimal' => '.',
'separator' => ',',
'prefix' => '',
'suffix' => '',
'exclude' => 0,
'id' => 'image_count',
'table' => 'node_galleries_gallery',
'field' => 'image_count',
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
),
));
$handler->override_option('filters', array(
'status' => array(
'operator' => '=',
'value' => '1',
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => FALSE,
'label' => '',
),
'id' => 'status',
'table' => 'node',
'field' => 'status',
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
),
'type' => array(
'operator' => 'in',
'value' => array(
'node_gallery_gallery' => 'node_gallery_gallery',
'photo_gallery' => 'photo_gallery',
),
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => FALSE,
'label' => '',
),
'id' => 'type',
'table' => 'node',
'field' => 'type',
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
),
));
$handler->override_option('access', array(
'type' => 'none',
));
$handler->override_option('cache', array(
'type' => 'none',
));
$handler->override_option('title', 'Photo Galleries');
$handler->override_option('items_per_page', 0);
$handler->override_option('distinct', 1);
$handler->override_option('style_plugin', 'table');
$handler->override_option('style_options', array(
'grouping' => '',
'override' => 0,
'sticky' => 0,
'order' => 'asc',
'columns' => array(
'gid' => 'gid',
'title' => 'title',
'image_count' => 'image_count',
'body' => 'body',
),
'info' => array(
'gid' => array(
'separator' => '',
),
'title' => array(
'sortable' => 0,
'separator' => '',
),
'image_count' => array(
'sortable' => 0,
'separator' => '',
),
'body' => array(
'separator' => '',
),
),
'default' => '-1',
));
$handler->override_option('row_options', array(
'inline' => array(
'gid' => 'gid',
'title' => 'title',
'image_count' => 'image_count',
'body' => 'body',
),
'separator' => ' ',
));
$handler = $view->new_display('page', 'Page', 'page_1');
$handler->override_option('path', 'galleries');
$handler->override_option('menu', array(
'type' => 'normal',
'title' => 'Galleries',
'description' => 'All Galleries',
'weight' => '0',
'name' => 'navigation',
));
$handler->override_option('tab_options', array(
'type' => 'normal',
'title' => 'Galleries',
'description' => 'All Galleries',
'weight' => '0',
));
#7
For reference:#613988: Views (again): Gallery Image size
#8
The way to do this properly is to provide a relationship that gives you the cover node for the given gallery node.
In other words, a Views relationship that goes from gallery_image back to node, but only picking the single node that is the cover. So your tables connect like this:
node (base of the view) ---(nid = gid)--- node_gallery ---(nid = nid, where is_over = 1)--- node (cover image)
You can then add any fields for nodes on the relationship to get title, image output, date created, etc etc.
Here is a patch with that.
I've also taken the liberty of:
- changing the label of the current 'cover image' field, because that only gets you a boolean
- adding some code comments for views data sanity ;)
#9
thanks @joachim. That's how I did in in NG3.x-dev -- you're pretty brave diving into 2.x views code! I don't have the time to review it, but I know there's plenty of people wanting better views integration on their 2.x installs. If I get a few reports of RTBC, then I'll commit this into 2.x-dev (as well as your other views patch at #613988: Views (again): Gallery Image size.
#10
@ALL
NG3 has awesome views integration. If somebody has to live with NG2 for the upcoming time you might want consider testing this patch and reporting back. Apart from ready-to-commit fixes I doubt there will be any further love for NG2 from this point on.
#11
NG2 is basically dead. Use NG3!