1

Love the module. My use case is to take programatically take the result of a view and load it into a colorbox. I can use views_get_view or views_embed_view to get a result array or a large html string. But how can I pass that to the colorbox?

Any help is greatly appreciated.

https://drupal.org/node/1991948

2
  • Welcome to stack exchange.
    – Sam Becker
    Jun 16, 2013 at 14:02
  • Any tips on how to Set the Image Format To Colorbox? @Sam152
    – kine456
    Jun 17, 2013 at 7:36

1 Answer 1

1

Put your view into a div with a wrapper that is hidden (ie, display:none;). Then you can use the following javascript:

$.colorbox({
    'inline' : true,
    'href' : $('.views-view-my-view'),
});

You must replace the 'href' attribute with the appropriate jQuery collection representing your view. Other customisations to the way your colorbox appears can be found here.

If you need some advice on placing a view on your page, here is a clean implementation:

function MODULE_preprocess_page(&$vars) {
  $vars['page']['bottom']['my_view'] = array(
    '#type' => 'container',
    '#attributes' => array(
      'id' => 'my-view-container',
    ),
    'children' => array(
      '#markup' => views_embed_view(...),
    ),
  );
}

In this case your selector for colorbox would be #my-view-container .view

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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