Hallo,

$text = 'link';
$entity_id = [file:fid];
$link = modal_entities_generate_link($text, 'file', $entity_id, $view_mode = 'preview', $style = 'large');
print render($link);

with this code the link is rendered correctly

<a href="/modal-entities/nojs/file/2467/preview" class="ctools-use-modal ctools-modal-modal-entities-large ctools-use-modal-processed" title="link">link</a>

but the result is always the same, full content view mode and medium modal.

Also, how can I add a class to the link? I d like to be able to change some settings in modal with

drupal_add_js(array(
    'my-modal-style' => array(
      'modalSize' => array(
        'type' => 'fixed',
        'width' => 250,
        'height' => 250,
      ),
    ),
  ), 'setting');

but I need at least to add a class to the link

tx
Simone

Comments

a.milkovsky’s picture

but the result is always the same, full content view mode and medium modal.

Sounds like a bug. View mode should be used in entity_view($entity_type, array($entity), $view_mode); inside of _modal_entities_popup(). I will have a look. (Hopefully today).

but I need at least to add a class to the link

Currently the module is not flexible enough for custom settings. But I am open to the ideas. If you have a working patch I would commit it with a pleasure.

I was thinking about a new hook_model_entities_style_info(), where you can provide own style with settings. Like:

function MAMODULE_model_entities_style_info() {
  $settings['my-modal-style'] => array(
      'modalSize' => array(
        'type' => 'fixed',
        'width' => 250,
        'height' => 250,
      ),
    ),
  return $settings;
}
cimo75’s picture

Hi,
it seems like the options from the .module file are not used at all. I tried to change them there but nothing changes in the modal.
S.

  • a.milkovsky committed d0643f4 on 7.x-1.x
    Issue #2499451 by cimo75, a.milkovsky: Style and view mode not changing...
  • a.milkovsky committed 11b0a9f on 7.x-1.x
    Issue #2499451 by cimo75, a.milkovsky: Style and view mode not changing...
a.milkovsky’s picture

Status: Active » Fixed

Fixed in new release. Please check now. Also added hook_modal_entities_style_info()

cimo75’s picture

Thanks for looking into this.
Now it is possible to choose the view mode for the modal (great!), but it is not possible to change the style, it seems like it always defaults to small.
Deleting compeltely the function
function modal_entities_modal_entities_style_info()
in your code makes it use the "large" style (which is what I want.).
Simone

a.milkovsky’s picture

Status: Fixed » Postponed (maintainer needs more info)

If you need the 'large' style simply use:

$link = modal_entities_generate_link($text, 'node', $entity_id, 'teaser', 'large');

Default is 'middle'. Could you provide your code?

cimo75’s picture

Ok that works I was a bit confused about the proper syntax.
Tx
Simone

a.milkovsky’s picture

Status: Postponed (maintainer needs more info) » Fixed

welcome

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.