Closed (fixed)
Project:
Views (for Drupal 7)
Version:
6.x-2.5
Component:
block displays
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
22 Apr 2009 at 07:19 UTC
Updated:
1 Apr 2011 at 08:37 UTC
I would like to load a block from views2 into a page via ajax. The block has many pictures and this slows down the site. I would like the page to load and when it is finished, load this block at the very end.
My line of thinking is that I should make an ajax call to a kind of template file that graps the right view from the database. I have no idea how to do this without loading the headers and all the rest I don't need.
The most dirty way I can imagine is to just load an entire new page with just that block in it (mysite.com/my/block/view) and extract the html I need with javascript. this would mean loading a lot of css and js and html for nothing.
Comments
Comment #1
dawehneri'm not sure whether views provides something but basically
1. define menu callback
2. do a menu callback like this
and get this with your js and print it anywhere. its returns a json array
PS: there seems to be a views_ajax menu callback, but i cannot figure how to use $_REQUEST
Comment #2
vacilando commentedI also would like to achieve AJAX loading of a views2 block. Subscribing.
Comment #3
dawehnerdid you tested my code?
Comment #4
dkruglyak commented@dereine: Could you package your code in a way that is easy to apply? Perhaps make a patch?
Would be very valuable to make this available at the block level, so that it would work outside of the Views module too.
Comment #5
mths commentedSorry for being slow to react, I had some other stuff on my mind.
I didn't test the code. I wouldn't know where to put it and how to call it. I know to little about Drupal.
Comment #6
esmerel commentedThis issue is a year old, it's likely either resolved or no longer relevant.
Comment #7
vacilando commented@esmerel, if you know there is a solution, please point to it. If not, you can ask people in the thread whether they consider it irrelevant.
Such threads are very useful as meeting points for people who look for answers to particular questions.
Thanks for your consideration.
Comment #8
merlinofchaos commentedOld threads that remain open are generally bad for the queue, unfortunately. esmerel's effort is to try and trim the Views' queue down enough that the maintainers can remain effective. For posts that are more discussion than anything, there's always the forum.
BTW, Views has an AJAX method. The appropriate thing to do is to turn on AJAX, take a look at what it does when it's enabling AJAX on a view (for example, with the pager) and then try to construct something that does the same thing. This thread doesn't look like it's helping anybody doing that. Other threads may have discussed doing this, I think.
Comment #9
maximpodorov commentedYou can use Ajax Blocks module.