1

I want to do something similar to views slideshow. The thing is my javascript is written already. I would like my javascript to be able to be integrated within the drupal framework from views. The JQuery just is a simple image slideshow like this one here. I just would prefer that I could show all or specific view field content instead of putting in the url in the javascript the long way. I want these images to come directly from a content type. Can you show me how?

  • 1
    Being a newbie doesn't justify to write confusing english :) okay i'm not a native speaker, but i still don't get what you actually want. – Daniel Wehner Jun 12 '12 at 5:37
  • @DanielWehner, +1 – niksmac Jun 12 '12 at 6:42
4

You could create a small module that will be called through ajax:

function MYMODULE_node_menu() {
    return array(//$items
        'MYMODULE/%' => array(
            'page callback' => 'MYMODULE_display_view',
            'page arguments' => array(1),
            'access callback' => TRUE,
            'type' => MENU_CALLBACK,
        )
    );
}
function MYMODULE_display_view($view_name) {
    // display your view depending on $view_name
   $view = views_get_view($view_name);
   $view->execute();
   echo $view->render();
}

Get a views html by making an ajax call using jQuery:

$(document).ready(function() {
   $.ajax('MYMODULE/YOUR_VIEW_NAME', {
           sucess:function(data) {
              // data will contain the html for your view
           }
   });
 });

You might find the following Drupal 7 Advanced Ajax helpful.

| improve this answer | |
  • 1
    Thanks for the link to the slides. Didn't know about it. It should be on d.o. – Countzero Jun 12 '12 at 8:46

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.