Posted by amirtaiar on December 8, 2010 at 6:19pm
| Project: | jCarousel |
| Version: | 7.x-2.0-alpha1 |
| Component: | Miscellaneous |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
When I try to implement the caruesel style for the view nothing happen and it goes back to the latest style (unformated).
Comments
#1
Am I the only one with this problem?
#2
see http://drupal.org/node/983820
Views support is still WIP
#3
Thank you.
Any timetable?
Can I use it without view? If not then why it publish in the D7 version?
#4
Yeah as stated Views doesn't currently work with jCarousel on Drupal 7. You can use jCarousel as an API still in the Drupal 7 version (see the help page at admin/help/jcarousel for examples). That and publishing a D7 version gets other users that are using the module to try and collaborate. I'm not using Drupal 7 yet so I don't have a need for it, but of course I'd like it to be working like everyone else.
#5
The integration with Views isn't working for me either. Would love to use it.
I tried looking at the suggestion Mori gave here: http://drupal.org/node/992472.
I didn't really understand it, and couldn't get it to work.
#6
I found a way how to get it to work. Probably the same way Mori did it. I wrote an article about it here: http://www.maartendeblock.com/article/drupal/a-working-views-slideshow-w...
#7
following issue
#8
Better module out there http://drupal.org/project/views_slideshow .... why reinvent the wheel?
#9
following issue, I got the same results in views the style jumps back to unformatted on D7
Thanks
#10
Here's a snippet I use until there will be a Views integration. It takes the Views result and formats it to get it inside a jcarousel. Obviously you will have to do some modifications to the view name. display ID and the fields you want to see .
<?php
$output = '';
// Since there is currently no Views integration for jCarousel, we use its
// API.
$view_name = 'VIEW-NAME';
$display_id = 'DISPLAY-ID';
$view = views_get_view($view_name);
$view->preview($display_id, array($collection->nid));
$items = array();
if (!empty($view->result)) {
foreach ($view->style_plugin->rendered_fields as $row) {
// Change this to get your field.
$items[] = $row['YOUR_FIELD'];
}
$options = array (
'buttonNextEvent' => 'mouseover',
'buttonPrevEvent' => 'mouseover',
);
$output .= theme('jcarousel', array('items' => $items, 'options' => $options));
}
?>
#11
that code gives me a couple of errors:
* Notice: Undefined variable: collection in eval() (Zeile 8 von /var/www/webxxx/html/modules/php/php.module(75) : eval()'d code).* Notice: Trying to get property of non-object in eval() (Zeile 8 von /var/www/webxxx/html/modules/php/php.module(75) : eval()'d code).
* Notice: Undefined index: field_image in eval() (Zeile 14 von /var/www/webxxx/html/modules/php/php.module(75) : eval()'d code).
* Notice: Undefined index: field_image in eval() (Zeile 14 von /var/www/webxxx/html/modules/php/php.module(75) : eval()'d code).
* Notice: Undefined index: field_image in eval() (Zeile 14 von /var/www/webxxx/html/modules/php/php.module(75) : eval()'d code).
...perhaps I shouldn't say errors, since it prints out "notice". But there is no carousel showing up...
#12
@anruether
$view->preview($display_id, array($collection->nid));Notice that I send my own custom argument, you should probably change it to your own argument (if you have any).
#13
Ok..i didn't know that that is an argument. I will have to learn some php that is used by drupal. I will give it a try! Thanks!
#14
I didn't get any output... this is my php and I tried it with different views:
<?php
$output = '';
// Since there is currently no Views integration for jCarousel, we use its
// API.
$view_name = 'produkte';
$display_id = 'page_1';
$view = views_get_view($view_name);
$items = array();
if (!empty($view->result)) {
foreach ($view->style_plugin->rendered_fields as $row) {
// Change this to get your field.
$items[] = $row[title];
$items[] = $row[field_image];
}
$options = array (
'buttonNextEvent' => 'mouseover',
'buttonPrevEvent' => 'mouseover',
);
$output .= theme('jcarousel', array('items' => $items, 'options' => $options));
}
?>
#15
Confirm the style jumps back to unformatted on D7 with 7.x.2.2-alpha1
#16
Confirm as well. Is the dev-team aleready working on this issue?
#17
No, not currently. I'd be happy to look at any patches, but I haven't yet started building client sites on Drupal 7.
#18
All is well, one just needs to register the files in the info file. There is another bug with the queries, thats up next on my list.
#19
Fixed a API calls, removed reference to the pager (probably should be removing views 2 support as well since there is no views 3 for Drupal 7). Also removed the query that would count the number of results of the view - we can just use count($view->result) instead, works fine.
So far tested with a display of 3 items of a set of 10, worked fine in cycle.
#20
One should also move the template file to the includes dir, but I can't do a diff on that for CVS.
#21
having problems applying the patch. can you post adapted files? I've overseen something manually i guess. Thx.
#22
Whats wrong with the patch? try moving to the module folder and do a patch -p0 < 992726-jcarousel-drupal7_0.patch
#23
Thanks @snufkin! I'll review when I get a chance. Curious to see if these changes work with the D6 version of Views also (2 or 3). It'd be great to get rid of that count query from all versions, since it's both an extra duplicate query and has some issues (like #1017582: Relative date-based filters not working).
#24
I took a look at this patch it looks like it would *almost* work, however there's a definite short-coming that would prevent it from actually working. Instead of this (admittedly really ugly looking piece of code):
$replacements = module_invoke_all('views_query_substitutions', $view);$count_query = str_replace(array_keys($replacements), $replacements, $count_query);
$result = db_query($count_query, $view->build_info['query_args']);
$count = 0;
while ($row = db_fetch_array($result)) {
$count++;
}
The count is just generated with this:
$count = count($view->result);I really wish this would actually work, but it isn't the same logic. The previous code actually determines how many items there are *total* in the whole carousel. The second just reports how many are on the current page. If you enable AJAX, the number of items on the first page is likely to be something small (like 4 or 10), which the total number of items will probably be 20 or more (since that's when you'd want to use AJAX). Maybe the previous code can simply be restored and it would work with Drupal 7's Views 3?
In any case, here's @snufkin's patch backported for Drupal 6 use, which needs to maintain both Views 2 and Views 3 compatibility.
#25
Here's a reroll with the problem I mentioned in #24 fixed. Still not great but at that code segment is doing what it was before the patch. I've also moved the jcarousel-view.tpl.php file as part of #998490: No such file or directory: jcarousel.views.inc, so that change is no longer necessary when testing this patch against HEAD.
Included are both D6 and D7 versions for consistency. Yes I know it's silly to update Views 2 code in D7, it's for consistency between versions for maintenance.
This patch still doesn't work the way you'd expect with AJAX results, but at least it doesn't throw any PHP or JS errors. When combined with AJAX the results are either missing or incorrect. Otherwise it looks like this gets Views working in D7, which is a start.
#26
After applying D7 patch still get the
'When trying to implement the carousel style for the view nothing happens and it jumps back to the latest style (unformatted)'
error.
Please advise.
#27
You need to flush your Drupal cache after applying the patch.
#28
I've committed these patches since it's definitely an improvement in our D7 Views support (which didn't work at all previously). I've separated out the remaining issue into #1053118: Views AJAX support does not work in Drupal 7.
#29
<?php$replacements = module_invoke_all('views_query_substitutions', $view);
$count_query = str_replace(array_keys($replacements), $replacements, $count_query);
$result = db_query($count_query, $view->build_info['query_args']);
$count = 0;
while ($row = db_fetch_array($result)) {
$count++;
}
?>
this actually doesn't work for me, I get the following error:
DOException: SQLSTATE[HY093]: Invalid parameter number: no parameters were bound: SELECT node.nid AS nid, node.title AS node_title, node.created AS node_created, 'node' AS field_data_field_image_node_entity_type, 'node' AS field_data_body_node_entity_type FROM {node} node WHERE (( (node.status = :db_condition_placeholder_0) AND (node.type IN (:db_condition_placeholder_1)) )) ORDER BY node_created DESC; Array ( ) in jcarousel_views_add() (line 121 of jcarousel-DRUPAL-7--2/includes/jcarousel.views.inc).whereas
$count = count($view->result);works just fine, and it returns the same count wether its ajax or not. D7 only, haven't tested it on d6 and views 2.#30
Oh, didnt see you committed while i was writing that reply. The error still stands though, but this time its line 129
#31
Oh hmm. I'll have to update my D7 sandbox. Probably a difference between APIs.
count($view->result); is not the same thing. That's counting the number of items on the current page not the number of items total on all pages. If you have a carousel that has 4 items on the first page but 16 items total, and Views only returns 4 items at a time, then the carousel is not going to show the other 12 items. But again this may be a moot point since AJAX support isn't working yet anyway. :P
#32
snufkin and I figured this one out with a little IRC session. Looks like I just needed to add a few filters to my view to reproduce the problem. The approach I used in #25 probably isn't going to work for Drupal 7. After testing and verifying this new approach works I've committed this patch.
#33
This works like a charm in Internet Explorer 7 & 8 but in Mozilla Firefox the display isn't correct.
Please advise.
Thank you!
#34
This has nothing to do with this issue. This is about getting the Views integration just working. Your comment relates to theming and is too vague to act upon anyway. Please file a new issue.
#35
Automatically closed -- issue fixed for 2 weeks with no activity.