I've created a table style view with a few content fields. Most of the fields are node reference. I'm trying to display the content of the referenced node in a modal from views links feature.

I've added this php to the header section of the view.

<?php  {
ctools_include('modal');
ctools_modal_add_js();
 }
?>

I've selected my field to use "Output this field as a link". From the 'link path' I'm using the token for my field and it seems like that is setup fine. For the 'link class' I have entered 'ctools-use-modal'

After I save the view, I return and click the linked field. A modal box does popup. The title says 'Loading...'. After a few seconds I get 'An error occurred at /mysite/path-to-node'. The path that is being displayed as an error looks to be the correct path I want.

Do I need to make a small module to tap into some more functionality from ctools for the linked field to be rendered inside the modal?

Any suggestions or pointers would be greatly appreciated.

Comments

aaronbauman’s picture

Version: 6.x-1.8 » 7.x-1.x-dev

did you ever figure this out?
i'm trying to do similar in d7

warmth’s picture

This should become a module like Modal Forms! I don't like how the nodes look in Colorbox or Lightbox2!

ankitchauhan’s picture

No need to create separate module. Add this code into header of your view, this is for default modal popup. Create a global text area and place the code below with text format php

ctools_include('ajax');
ctools_include('modal');
ctools_modal_add_js();

If you want custom modal popup add this also to header

$sample_style = array(
    'ctools-sample-style' => array(
      'modalSize' => array(
        'type' => 'fixed',
        'width' => 600,
        'height' => 500,
        'addWidth' => 20,
        'addHeight' => 15,
      ),
      'modalOptions' => array(
        'opacity' => .5,
        'background-color' => '#000',
      ),
      'animation' => 'fadeIn',
      'modalTheme' => 'CToolsSampleModal',
      'throbber' => theme('image', array('path' => ctools_image_path('ajax-loader.gif', 'ctools_ajax_sample'), 'alt' => t('Loading...'), 'title' => t('Loading'))),
    ),
  );

  drupal_add_js($sample_style, 'setting');
  ctools_add_js('ctools-ajax-sample', 'ctools_ajax_sample');
  ctools_add_css('ctools-ajax-sample', 'ctools_ajax_sample');

you can customize accordingly. Then create a custom module and implement hook_node_view() and put the following code

    $output = render($node->content);
    ctools_include('modal');
    ctools_modal_render($node->title, $output);
    exit;

Now in you view, select any view field, on which you want to show modal popup (i.e. content it or content title),

  1. uncheck Link this field to the original piece of content if it is checked
  2. Click on Rewrite the Result and check Output this field as a link
  3. fill the link path whatever you want (i.e node/[nid]/nojs)
  4. Add link class ctools-use-modal ctools-modal-ctools-sample-style

It worked for me, hope for you too.

ankitchauhan’s picture

Status: Active » Needs review

forgot one thing

you wound need to enable ctools_ajax_sample module

aaronbauman’s picture

I ended up using colorbox_node

damienmckenna’s picture

Issue summary: View changes
Status: Needs review » Active

Please only change the issue status to "needs review" when there's an actual patch to test. Thank you.

maximpodorov’s picture

2alokjha’s picture

Getting Ajax http error

supriyarajgopal’s picture

Hi,

Find my solution here.

Regards,
Supriya Rajgopal

mustanggb’s picture

Status: Active » Closed (outdated)