I have the core Contextual Links module enabled, but contextual links for my views block aren't appearing. This is because blocks don't have the necessary classes to make contextual links work properly...

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

BWPanda’s picture

Status: Active » Needs review
FileSize
646 bytes

Here's a patch that adds the necessary wrapper to blocks to make contextual links work (taken from https://api.drupal.org/api/drupal/modules!block!block.tpl.php/7).

I also removed the if() statement from block->subject as it was pointless.

Anonymous’s picture

Just taken a look at this and it seems the contextual links are actually still there but thanks to the core contextual.css file they're hidden by default.

Rather than add in the excess container I've removed the system contextual CSS & added in a small amount so they should now be displayed in the standard manner.

Regarding the if statement around the block subject: I took a look & without any markup the header was a bit out of place so I've added in a h3 tag to give it a bit of definition (& as such requires the if statement).

I've rolled a new release but it takes a while to come through so this patch should do in the meantime:

BWPanda’s picture

Status: Needs review » Needs work

Hmm, doesn't work properly for me...
I'm using the git version and so have pulled your changes down, but now the 'Configure' text link is permanently showing (not just on hover), and the cog icon is gone.

If you didn't want the full div code that my patch added, I worked out that the only part actually needed is the class, so you could just add the following to the block.tpl.php file and get contextual links to work:

<div class="<?php print $classes; ?>>
  [...]
</div>

Don't want to roll a new patch without hearing your thoughts since it'll mean removing most of what you just committed...

Anonymous’s picture

Status: Needs work » Closed (works as designed)

As far as I'm aware the cog icon is just the configure link displayed as an icon rather than the link.

In terms of functionality the configure links are now visible so I think that will do for the theme itself & users can then style the configure link in any particular way they choose.

BWPanda’s picture

In terms of functionality the configure links are now visible so I think that will do for the theme itself & users can then style the configure link in any particular way they choose.

Are you sure?

Drupal core styles the core contextual links as small cog icons that are hidden until you hover over the area in question. What you've just done is strip away Drupal's core styling, force users to re-style the contextual links (just to get them back to looking how they should) and fundamentally change the way links are displayed (permanently, not just on hover).

I would understand if you had a particular style for the links that fit with your theme, but to remove all styling and force users to re-style something that should be done out-of-the-box... I think that's the wrong approach.

Anonymous’s picture

The whole goal of Elementary is to reduce the theme to the bare minimum of what is actually needed, if users need something more then they can adapt the theme as they see fit.

In my view the contextual links provide a quick link to edit a particular bit of content, as this is still possible I think it's fine.