Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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;
Comment | File | Size | Author |
---|---|---|---|
#1 | 2323861-1-panels-attributes.patch | 503 bytes | pfrenssen |
Comments
Comment #1
pfrenssenComment #2
mglamanWorks perfect. Will definitely make utilizing data or ARIA attributes.
Also fixing code example, because I copy pasted and thought patch was broken.
Comment #4
mrjmd CreditAttribution: mrjmd commentedComment #5
japerryOhh yes nice feature. Fixed.
Comment #8
sardara CreditAttribution: sardara at Randstad Digital commentedI 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 .
Comment #9
japerry3.6-dev added back in.
Comment #10
gmclelland CreditAttribution: gmclelland commented@japerry - I'm still not seeing this in the dev version.
Comment #12
PieterDCI 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.
Comment #13
DamienMcKennaConfirmed, this was accidentally reverted in #2408729: Hardcode the last released Panels version in the info file. The patch still applies.
Comment #14
DamienMcKennaComment #15
DamienMcKennaComment #17
DamienMcKennaThis was committed.