By jjkiesch on
i've been looking around for a few tutorials on using ajax in modules but most of them involve sending a request and returning the results in JSON. what i want to do is to simply load the html of either a teaser or a full node and get the result returned back as html, without the rest of the template as well.
what would be the best way of doing that? are there any examples or modules to look at as a reference?
Comments
Possible solution
Without actually trying it out I think you could write your ajax PHP file like this:
The actual ajax call can be made using jQuery Javascript code:
It's up to you to determin the $nid that should be loaded. You could pass it as a $_POST
variable using the same jQuery load function. For more info check:
http://docs.jquery.com/Ajax
PS: Sorry I just realized this is for Drupal 6 but the code I posted is for Drupal 5. Not sure if it will work there, maybe you
need to look up the Drupal 6 API for similar functions.
Solution for Drupal 6
For a Drupal 6 ajax PHP file placed in your root folder could look like this
Does bootstrapping drupal in
Does bootstrapping drupal in this way ignore template files? I am unable to get a themed node using this method (i.e. to include variables added by theme_preprocess_node).
Permissions and node access?
Anyone know if this method can still see the logged in user, and whether they have permissions to view the node?
I ultimately ended up with a
I ultimately ended up with a very small module that has a single menu callback and function to display the node_view:
This will play nice with the currently logged in user. Mess with the 'access arguments' to only allow this for certain users. I use an ajax callback to hit this url and bring in node data on demand.
Ajax
Is there easy way to use load node using ajax ang i am using drupal 7 now. Every time i click my menu something like div will change and also the node_url wil change also..