I'm getting either an SQL Error - an empty block - or the block says it's getting data but never doesn
| Project: | AJAX Views |
| Version: | 5.x-1.0 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | febbraro |
| Status: | closed |
Jump to:
Depending on the settings I use I'm having different issues but none seem to work.
If I have in the arguments section "Return Page Not Found" - there's no data
If I put Display All Values it says it's loading the content but never does.
If I put any of the Summary options I get an SQL error - this one is for the Summary/Unsorted...
user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIMIT 0, 5' at line 1 query: SELECT count(node.nid) AS num_nodes FROM node node WHERE (node.status = '1') GROUP BY LIMIT 0, 5 in /home/.laos/hdmann/littlewaystosave.com/includes/database.mysql.inc on line 172.
I've tried the instructions provided in the documentation on several different views and seem to come up with the same issue.
Any ideas?
Many Thanks,
Heather

#1
same problem here...even without arguments added
#2
This was built to work with "Display All Values" for the argument. Return page not found will obviously return no rows, not sure about the other Summary settings but the SQL error probably has something to do with the paging.
If you look at the source HTML, you should be able to plug the URL in the $.get into your browser and bring up just the content to be loaded. See if that works or if it just hangs, the content returned from this URL is what replaces the "Loading..."
Does your view provide a Page with a url?
#3
thanks for the response!
i do have it set to return all values, but im embedding the block....i created a page url for the view itself and that DOES return data but it doesnt seem to be utilizing ajax...just the regular pagination ( no loading icon or ajax refresh)
so, how can i embed this in my page?? ive used the proper code and im not sure how to use the $get idea...again...the view itself doesnt seem to be ajaxy:
http://www.foliomag.com/yyajax
thanks!!
randy
#4
There are a couple of ways to embed the view block. The first and easiest way it to just put the view block in a region and have that region displayed where you want. However if you have a regular Drupal page (specified with PHP as the input format) you can do the following
$view = views_get_view('yyajax');print views_build_view('block', $view);
This will add the 2 javascript blocks to your page. (make sure you are including $scripts) One is ajax_views.js and the other is an inline bit to perform the initial remote get on the rendered block view in your page.
From your site it looks like yyajax is the URL for the page of your view, so you'll need to try to include the view block on another page. To see that the content will appear just go to http://www.foliomag.com/yyajax/ajax (this uses the AJAX Selector argument) so it appears that you at least have the argument setup correctly. :-)
HTH,
Frank
#5
thanks for responding!
what you suggested is how i originally implemented it...and i included the js and css call myself in the header. all i get is the unlodoading progress bar!
the "yyahax" page was just the page view for the view itself...
thanks!
randy
#6
I am also only getting a "Loading content for xxxxxxx" in my block. I also have a regular view that is working. I am adding both views as blocks to a region. I am using the same criteria for the AJAX version of the view except I added the "AJAX Views: AJAX Selector = Display All Values" for argument. I recently upgraded to Drupal 5.6, does the AJAX views only work with lower versions of Drupal?
-Drew
#7
well its not working for a 5.1 install
#8
I have it working on a 5.2, 5.3 and a 5.6 install.
What JS is included inline to load the block itself? Do you have any javascript errors on your page that includes this block? (Firebug, Error Console or IE Dev toolbar help with any error reporting?)
Any public URLs so I could take a look?
#9
Thanks for helping us figure this out! See:
http://www.tribalectic.com/Drupal/content/body-piercing-articles-and-inf...
> What JS is included inline to load the block itself?
I don't see any I see this as the block:
<div id="block-views-healing_articles_ajax" class="block block-views"><h2 class="title">Healing Articles</h2>
<div class="content"><div class='view view-healing-articles-ajax'><div class='view-content view-content-healing-articles-ajax'><img src="/Drupal/misc/progress.gif" alt="Progress" title="" width="20" height="20" /> Loading content for Healing Articles</div><div class='more-link'><a href="../articleson/healing"><img src="http://www.tribalectic.com/Drupal/sites/all/themes/labret/images/more_ot.gif" width="49" height="16"></a></div></div>
</div>
</div> <!-- /#block-views-healing_articles_ajax -->
I don't see any errors in Firebug.
-Drew
#10
Ok, I see the problem, I am just not sure what is happening.
It is trying to replace the view block with the class .view-content-healing_articles_ajax with the content from http://www.tribalectic.com/articleson/healing/ajax
The problem is that for some reason the view class is rendered as .view-content-healing-articles-ajax (hyphens, not underscores) The block view id is rendered correctly though, "block-views-healing_articles_ajax"
Did you do something to change the way the class names are rendered?
#11
would imploding the views list make this work?
in template.php:
function phptemplate_views_view_list_nameofview($view, $nodes, $type) {
$fields = _views_get_fields();
$taken = array();
// Group our nodes
$set = array();
foreach ($nodes as $node) {
$set[$node->node_title][] = $node;
}
// Set up the fields in nicely named chunks.
foreach ($view->field as $id => $field) {
$field_name = $field['field'];
if (isset($taken[$field_name])) {
$field_name = $field['queryname'];
}
$taken[$field_name] = true;
$field_names[$id] = $field_name;
}
// Set up some variables that won't change.
$base_vars = array(
'view' => $view,
'view_type' => $type,
);
$output = '';
foreach ($set as $label => $nodes) {
$items = array();
foreach ($nodes as $i => $node) {
$vars = $base_vars;
$vars['node'] = $node;
$vars['count'] = $i;
$vars['stripe'] = $i % 2 ? 'even' : 'odd';
foreach ($view->field as $id => $field) {
$name = $field_names[$id];
$vars[$name] = views_theme_field('views_handle_field', $field['queryname'], $fields, $field, $node, $view);
if (isset($field['label'])) {
$vars[$name . '_label'] = $field['label'];
}
}
$items[] = _phptemplate_callback('views-list-nameofview', $vars);
}
if ($items) {
$output .= implode('item_list', $items);
}
}
return $output;
}
#12
I see now. It is an upgrade in part of the views module that now calls a function, views_css_safe. I will update the module, test it, and get a new release out hopefully by tomorrow. Sorry about that.
#13
You are Awesome!!!
looking forward to it!
randy
#14
This is excellent news. Sorry I couldn't be of more help but I'm new to Drupal so am still wading around trying to figure things out. It is great to see everyone jumping on board to get things figured out.
Well done guys!
Thanks :)
Heahter
#15
Thanks so much for your help, I am very excited about this module!
-Drew
#16
This has been fixed and released as 5.x-1.1. Please download the new release and give it a try. Thanks for finding this bug.
#17
i just tested..but same issue!
here is my head call:
embed code:
<?php
$view = views_get_view('nameofview');
print views_build_view('block', $view);?>
and finally, divs around the content list:
Loading content for#18
i just tested..but same issue!
here is my head call:
<script type="text/javascript" src="/modules/ajax_views/ajax_views.js"></script><link rel="stylesheet" type="text/css" href="/modules/ajax_views/ajax_views.css" />
embed code:
<?php
$view = views_get_view('nameofview');
print views_build_view('block', $view);?>
and finally, divs around the content list:
<div class='view view-nameofview'><div class='view-content view-content-nameofview'><img src="/misc/progress.gif" alt="Progress" title="" width="20" height="20" /> Loading content for </div></div>
</ul>
</div>
</div>
</div>
</div>
and i get the progess bar loading nothing...i should note that i also tried embedding as a regular block,
<?php $block = module_invoke('views', 'block', 'view', 'nameofview);print $block['content];?>and i also included
print $scriptsas well as calling directly as above..i should also note that i did not see the $script return printing out the modules css and javascript calls...from the looks of it, its still returning dashes instead of _
thanks!
randy
#19
Hey Randy,
It is supposed to return dashes instead of _ that was the original problem. You should have one more block of JS code that does the initial load. It should look something like
$(document).ready(function() {$.get('/viewurl/ajax', {page: 0}, function(data, status) {
$('.view-content-nameofview').html(data);
});
})
Do you have that anywhere in your head section? It performs the initial load. Without it you are likely to just see the "Loading....." forever. Also, if you do have that, post a public URL if you could and I'll take a peek.
#20
i didnt have that! i put it in manually and same thing...changing the view name and url...
id show you a public page, but its the homepage!..ill leave this up for a few...
http://www.foliomag.com...scroll to the middle box area
thanks!
randy
#21
I don't see the block in the home page, but that is ok for now. One otherthing I see missing is that you dont have /misc/jquery.js included anywhere. jQuery is a requirement for this to work.
<script type="text/javascript" src="/misc/jquery.js"></script>Do you have that in your head section?
#22
the block is there....you may be seeing a cached page...do a refresh
i added the jquery query, but still no dice...sorry to be such a pain!
here is my head code fyi:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
<head>
<script type="text/javascript" src="/modules/ajax_views/ajax_views.js"></script>
<script type="text/javascript" src="/misc/jquery.js"></script>
<link rel="stylesheet" type="text/css" href="/modules/ajax_views/ajax_views.css" />
<script type="text/javascript">$(document).ready(function() {
$.get('/yyajax/ajax', {page: 0}, function(data, status) {
$('.view-content-1linkswithyellowbrixajax').html(data);
});
})</script>
#23
Hey, no problem.
What is happening now on your site is that mootools is killing jQuery, so the ajax_views JS can't execute b/c mootools and jQuery have some sort of namespace or function name conflict.
Any chance you can get rid of mootools in favor of jQuery? or you can read this http://drupal.org/node/121631 I'm not saying that discussion works b/c it looks like a lot of work to be done, but some people have reported success. I guess it depends how much of mootools functionality you use on your site.
Anyway, I think if you simply remove the mootools include it will work. Even if the rest of your site wont, you could test it anyway. :-\
Good luck, let me know what you turn up.
#24
that was totally it!!!! i removed mootools and it worked!!!!!
THANK YOU
THANK YOU
THANK YOU
THANK YOU
THANK YOU
THANK YOU
THANK YOU
THANK YOU
THANK YOU
#25
Seems to be working great now! I need to update the theming a bit but it works, thanks a TON!
-Drew
#26
OK, the problem I am having now is that if you click on the title of the view ("Healing Articles") it takes you to a page view with AJAX. I want the page view to be the regular view with teasers, any idea why it is replacing the regular view page with the AJAX page view?
http://www.tribalectic.com/Drupal/content/body-piercing-articles-and-inf...
-Drew
#27
Are you manually adding the JavaScript? What is happening, if you notice, is that your page appears correctly, then it gets replaced with the AJAX content. That is because the $(document).ready( ); section is included and it is replacing the main page view body (designated with class view-content-viewname, just like the block).
I can probably update the module to only replace content that is within a .block to help you, but it also seems like that JS should not be included on that page.
Does that make sense?
#28
I am not including any extra JS on that page, I am using the default themes/pages. Since the view only works with blocks right now it would be great if you could update the module to only replace content in .block.
-Drew
#29
I'll investigate a few options. The thing that might not work is when you go views_build)view('block', ....) it probably does not wrap it in a div with a .block. Another option is to just do an outer div with a specific non conflicting id/class to catch on. I'll evaluate it. I created an issue for this, http://drupal.org/node/213831
#30
Please let me know what you come up with, we'd like to use these AJAX views. I am adding them as a block now.
-Drew
#31
worked for me! Thanks :)
Heather
#32
Drew,
Check out release 1.2 for the fix.
Good luck.
#33
Works great now! Which functions are used to modify the output of the view? I have some other views (like buddylist, user gallery, etc.) that I would like to use AJAX for. Can this module be used for things like that? Those views are mostly images. Which functions would I need to modify?
-Drew
#34
Look at the docs, http://drupal.org/node/210926. It covers all the various theming hooks available.
Glad it works now, good luck!
#35
#36
Hi, I a was trying to test this module's functionality against Dynamic View's today but ran into a road block. I have everything set up according to documentation but when the block tries to load I get this error in Firebug:
[Exception... "'Permission denied to call method XMLHttpRequest.open' when calling method: [nsIDOMEventListener::handleEvent]" nsresult: "0x8057001e (NS_ERROR_XPC_JS_THREW_STRING)" location: "" data: no]
Which apparently says that my database is denying your module access, I guess. I'm not a coder so I'm not sure what to make of it :).
#37
I think that error message is misleading. Not exactly sure what it is saying, but lets see if you can at least access the ajax page view.
Can you try going to the URL that is specified in the pages javascript? To do that, view the page source, look for a URL ending in /ajax in the page header, the code will look something like this...
$(document).ready(function() {$.get('/viewurl/ajax', {page: 0}, function(data, status) {
$('.view-content-nameofview').html(data);
});
})
So what you will do is, in your browser address bar, type http://yourservername/viewurl/ajax (using the example from above, your url will be different) you should see a page with basically no formatting. If you see that page, then you have access to the view page, and something else on your site is causing an error.
Also, can you paste that javascript snippet from your site here, if it is not working?
HTH,
Frank
#38
The view does show up if I go to the url, but I still get the error in firebug. This is what the javascript snippet looks like:
<script type="text/javascript">$(document).ready(function() {$.get('//media/image/ajax', {page: 0}, function(data, status) {
$('.ajax-view-block-image-gallery').html(data);
});
})</script>
It seems pretty standard. On a side note, if I add an extra argument like Taxonomy Term Names, it will display the term names and not give me a firebug error, but the ajax view still will not show up.
Edit: It appears to be adding an extra leading / but my views url has no leading / set, the field looks like "media/image". Why in the world would it be doing that? O_o