In #2169571: Impossible to set attributes on Panels panes the standard $attributes were added to panel-pane.tpl.php. However currently it is only possible to change the attributes on a pane using template_preprocess_panels_pane(). It would be very helpful to also allow to set this from within a content type plugin itself. We can already set the CSS ID and classes alongside a host of other things, but not the attributes.

An example:

function my_content_type_render($subtype, $conf, $args, $context) {
  $content = new stdClass();
  $content->title = t('My title');
  $content->content = '<p>My content.</p>';

  // We can already set the CSS class and ID properties.
  $content->css_class = 'my-class';
  $content->css_id = 'my-id';

  // Let's also allow to set other attributes!
  $content->attributes = array(
    'data-my-data' => 9000,
    'draggable' => 'true',
    'tabindex' => 20,
  );

  return $content;
CommentFileSizeAuthor
#1 2323861-1-panels-attributes.patch503 bytespfrenssen
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

pfrenssen’s picture

Status: Active » Needs review
FileSize
503 bytes
mglaman’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community

Works perfect. Will definitely make utilizing data or ARIA attributes.

Also fixing code example, because I copy pasted and thought patch was broken.

mrjmd’s picture

japerry’s picture

Status: Reviewed & tested by the community » Fixed
Issue tags: +SprintWeekend2015

Ohh yes nice feature. Fixed.

  • japerry committed 5aaee22 on 7.x-3.x authored by pfrenssen
    Issue #2323861 by pfrenssen: Allow to set pane attributes from within...

Status: Fixed » Closed (fixed)

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

sardara’s picture

Status: Closed (fixed) » Reviewed & tested by the community

I have to re-open this issue as the code the patch provides was unfortunately removed by another commit, so it doesn't show up in 3.5 and 3.x .
The issue that removed the code is #2408729: Hardcode the last released Panels version in the info file with the commit 97d0568.
This patch still applies against latest 7.x-3.x .

japerry’s picture

Status: Reviewed & tested by the community » Fixed

3.6-dev added back in.

gmclelland’s picture

@japerry - I'm still not seeing this in the dev version.

Status: Fixed » Closed (fixed)

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

PieterDC’s picture

Status: Closed (fixed) » Reviewed & tested by the community

I also still don't see this in the dev version. So, I reopened this issue. This patch still applies against latest 7.x-3.x, albeit with an offset.

DamienMcKenna’s picture

Confirmed, this was accidentally reverted in #2408729: Hardcode the last released Panels version in the info file. The patch still applies.

DamienMcKenna’s picture

DamienMcKenna’s picture

  • japerry committed f02e837 on 7.x-3.x
    Issue #2323861 by pfrenssen: Allow to set pane attributes from within...
DamienMcKenna’s picture

Status: Reviewed & tested by the community » Fixed

This was committed.

Status: Fixed » Closed (fixed)

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