4

I know this can be done through jQuery alone, but I'm interested in knowing if there any Drupal 7 ways of achieving this:

I want to use AJAX to serve all non-admin pages on my site. Also I don't want it to just replace parts of a page, but load entire pages over AJAX. The AJAX Framework allows loading partial contents over AJAX based on various triggers. But I want to make a URL based navigation system.

Here are the things I want to accomplish:

  • Redirect http://example.com/node/1 to http://example.com/#!/node/1. So search engines can index the node normally.
  • Drupal reads the string from URL (node/1) and fetches the relevant string in json format.
  • Insert the resulting data into page and replace existing content.
  • Refreshes blocks that should appear on the corresponding page.
  • Refreshes title in browser (optional).
  • Needs to work with Panels.

If I create a new module, what functions and/or frameworks in Drupal can I use to make this work?

Thanks.

-Kaustav

1

I'm searching also a solution to do that. I would like to allow users to choose witch content type is displaying in a region.

I started by create one block by region and inside I put different functions like the following one to get different content.

node_view_multiple(array($node->nid => $node), $display_type); // To get a node.
module_invoke($module, 'block_view',$delta); // To get a block.
panels_mini_block_view($minipanel_name); // To get a mini panel.

Now, with the CSS ID of the block, I will try to refresh them using AJAX link. I think I will have to override all the links of Drupal to somethings like main/nojs/#div_region_id/[drupal-url] (e.g. main/nojs/block-content/node/1) and add them a class="use-ajax".

The management what is refresh will be in ajax_callback_response().

$commands[] = ajax_command_html('#block-content', $output );
$page = array('#type' => 'ajax', '#commands' => $commands);
ajax_deliver($page);

Another way may be also with the Content page module.

  • Thanks @jonathan. My aim is similar to what the Asynchronous module does for Drupal 6, i.e., rewrite all drupal links on the fly and pull in data from Drupal through JSON. – kaustavdm Nov 15 '11 at 12:55
  • The Services module can also be an option. I have not tried it though. – kaustavdm Nov 15 '11 at 12:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.