Skip to content

Commit

Permalink
Added data id
Browse files Browse the repository at this point in the history
  • Loading branch information
DQ26525 authored and DQ26525 committed Sep 1, 2020
1 parent 72bcee4 commit eef6d86
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions plugins/content_types/recommender.inc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ $plugin = array(
//'edit form' => 'ting_inspiration_list_content_type_edit_form',
'render callback' => 'ting_recommender_content_type_render',
'category' => t('Ting'),
//'required context' => array(new ctools_context_required(t('Inspiration List'), 'node')),
'required context' => new ctools_context_required(t('Ting object'), 'ting_object'),
'render last' => TRUE,
);

Expand All @@ -23,9 +23,14 @@ function ting_recommender_content_type_render($subtype, $conf, $panel_args, $con
// Define the return block.
$block = new stdClass();
drupal_add_js('https://cdn.bibspire.dk/ddbcms.js', 'external');
$object = isset($context->data) ? ($context->data) : NULL;
$data = '';
if (isset($object)) {
$data = 'data-ting-object-id="' . $object->getId() . '"';
}

// Set block content.
$block->content = '<a name="recommender"></a><div id="ting-recommender"></div>';
$block->content = '<a name="recommender"></a><div id="ting-recommender" ' . $data . '></div>';
return $block;
}

Expand Down

2 comments on commit eef6d86

@holt83
Copy link

@holt83 holt83 commented on eef6d86 Feb 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using context required ting object means that it can not be used on ting_collection pages.

Think we need to make them both optional:

'required context' => array(
  new ctools_context_optional(t('Ting object'), 'ting_object'),
  new ctools_context_optional(t('Ting collection'), 'ting_collection'),
),

@holt83
Copy link

@holt83 holt83 commented on eef6d86 Feb 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR that fixes the issue i mentioned above: #1

Please sign in to comment.