I just tested using the lastest Panels 3.x-dev and Ctools 1.x-dev.
-- I added a pane Menu>Development. All it provided was "Edit block", no "Edit menu links".
-- Menu block content panes doesn't have a "Edit block" or "Edit menu links."
-- I added a pane Widgets>User Login. It provides a "Edit block" link, but clicking it causes a fatal error.
-- I added a pane Widgets>Powered By Drupal. It provides a "Edit block" link, but clicking it causes a fatal error.
-- I added a pane Menus>Development (which is provided by Devel module). It provides a "Edit block" link, but clicking it causes a fatal error and no "Edit menu links".

I'll try to add submit a patch that covers the following:
1...User added menus at /admin/structure/menu/add
2...system blocks with menu links - Like "Navigation"
3...For the Menu Block module's menus, see #2400145: add "Edit menu links" to the Panels pane links dropdown menu.
4...module provided menu blocks like Devels or Features
5...fixes fatal errors on some "Edit block" links and provides "Edit menu links"

Just so we are clear, here is a screenshot of what I'm talking about.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

gmclelland’s picture

I'm guessing this code would go in:

panels/plugins/display_renderers/panels_renderer_editor.class.php:

to be included in function get_pane_links or should it just be on it's own like:

/**
 * Implements hook_get_pane_links_alter().
 */
function panels_get_pane_links_alter(&$links, $pane, $content_type) {
// add an Edit view link for views block displays
if ($pane->type === 'views') {
  $path = explode('-', $pane->subtype);
  $view_name = $path[0];
  $display_name = $pane->configuration['display'];

  $destination = array('destination' => current_path());
  $links['top'][] = array(
    'title' => t('Edit view'),
    'href' => url('admin/structure/views/view/' . $view_name . '/edit/' . $display_name, array('query' => $destination, 'absolute' => TRUE)),
  );
}

// add a Edit block link for custom blocks or views blocks
if ($pane->type === "block"){
  $name_of_block = "";
  $prefixed_name = $pane->subtype;

  // breakup the subtype string
  $exploded_subtype = explode('-', $pane->subtype);

  // contains view- or block-
  $subtype_prefix = $exploded_subtype[0] . '-';

  // remove the prefix to get the name
  $name_of_block = ltrim( $prefixed_name, $subtype_prefix);

  $links['top']['edit_custom_content'] = array(
    'title' => t('Edit block'),
    'href' => url('admin/structure/block/manage/' . $name_of_block . '/edit', array('absolute' => TRUE)),
    'attributes' => array('target' => array('_blank')),
  );
}

merlinofchaos’s picture

Hm. No I'd put hooks directly in panels.module, definitely not in a class file.

gmclelland’s picture

Status: Active » Needs review
FileSize
1.6 KB

Thanks @merlinofchaos! Here's a patch. Hope that helps

Panels 3.x-dev already has support for edit links for Mini Panels and custom content panes. Now we just need to finish it and add edit links for blocks(this issue) and views #1948278: Get an edit link for the view panes in Page Manger.

gmclelland’s picture

Oops.. I didn't see the comment about the Deprecated functions. Better add my stuff above that line. Here is a new patch.

DamienMcKenna’s picture

Status: Needs review » Needs work

Given the Views integration is already handled by #1948278: Get an edit link for the view panes in Page Manger, why not remove the Views integration from this patch and improve the other one as needed?

gmclelland’s picture

@DamienMcKenna - Well, I wasn't quite sure of where the code for views blocks should go? Maybe it should go directly in the views.module file? The patch in #1948278: Get an edit link for the view panes in Page Manger for views panes goes in the views_content module.

I'll try to update both patches (here and the views modules)

gmclelland’s picture

Status: Needs work » Needs review
FileSize
1.16 KB

Ok, I split out the code into another issue for views. #2387193: Get an edit link for the views blocks in Page Manger

Here is a new patch for this issue.

japerry’s picture

Status: Needs review » Needs work

gmclelland, shouldn't the link be: 'admin/structure/block/manage/block/' . $name_of_block . '/configure' ?

gmclelland’s picture

Status: Needs work » Needs review
FileSize
1.17 KB

@japerry - yes I think your right. Here is an untested updated patch with the change.

gmclelland’s picture

Status: Needs review » Needs work

Noticed it has 'edit_custom_content' and it instead needs to be 'edit_block'. I'm also going to try to include an edit link for menu blocks as well.

gmclelland’s picture

Title: Add "Edit block" custom menu items in pane dropdown links » Add "Edit block, menu links, and field" link items in pane dropdown links
Status: Needs work » Needs review
FileSize
2.23 KB

Here is a patch that adds "Edit block", "Edit menu links", and "Edit: fieldname" links. I took and had to modify the code from @bobodrone PAL module https://www.drupal.org/sandbox/bobodrone/1497388

Hope that helps

gmclelland’s picture

The patch in #11 adds Edit field links support, but it uses a sql query per field and I'm not sure how it works when a field is shared between two content types. It does this because you have to know the field's bundle to edit the field.

After more testing, I can't find a way to reliably get Field edit links because they require the field instance's bundle name in the link.

So were back to just Blocks and Menu links. Here is a new patch. Hope that helps

Status: Needs review » Needs work

The last submitted patch, 12: 2381319-add-edit-block-in-pane-dropdown-links-12.patch, failed testing.

gmclelland’s picture

Here is a reroll to accommodate the latest changes in dev.

gmclelland’s picture

Status: Needs work » Needs review
Michelle’s picture

I have been trying to test this and am confused. Without the patch, blocks have "configure block" and menus have "configure block", "list links" and "edit menu" in the pane drop down. What is this patch adding? It looks like it's just making minor changes to the existing block link and then adding in an entry for menus that must already exist somewhere else because it's already there in the drop down.

I'd be happy to test this if you could clarify the steps. :)

gmclelland’s picture

Title: Add "Edit block, menu links, and field" link items in pane dropdown links » Refactor "Edit block" and add "Edit menu links" items in pane dropdown links
Related issues: +#2400145: add "Edit menu links" to the Panels pane links dropdown menu
FileSize
4.31 KB
118.98 KB

Hi Michelle. Yes your right, this is confusing. After more research, this was more complex than I thought.

I just tested using the lastest Panels 3.x-dev and Ctools 1.x-dev.
-- I added a pane Menu>Development. All it provided was "Edit block".
-- Menu block content panes don't have a "Edit block" or "Edit menu links."
-- I added a pane Widgets>User Login. It provides a "Edit block" link, but clicking it causes a fatal error.
-- I added a pane Widgets>Powered By Drupal. It provides a "Edit block" link, but clicking it causes a fatal error.
-- I added a pane Menus>Development (which is provided by Devel module). It provides a "Edit block" link, but clicking it causes a fatal error.

I'll try to add submit a patch that covers the following:
1...User added menus at /admin/structure/menu/add
2...system blocks with menu links - Like "Navigation"
3...For the Menu Block module's menus, see #2400145: add "Edit menu links" to the Panels pane links dropdown menu.
4...module provided menu blocks like Devels or Features
5...fixes fatal errors on some "Edit block" links and provides "Edit menu links"

Just so we are clear, here is a screenshot of what I'm talking about.

Hope that helps

gmclelland’s picture

Issue summary: View changes

Updating issue summary.

Michelle’s picture

Status: Needs review » Needs work

Ah, screenshot helps tons. I was in the wrong spot! I was viewing a page and looking at the dropdowns there, not in the page building area.

Based on you saying that you're going to try and do a new patch, I'm setting this to "Needs work". Not sure how much more contrib time I will have but I will try to review the new one when you have it.

gmclelland’s picture

Status: Needs work » Needs review

Hi @Michelle, setting this back to NR. See the patch in #17. I shouldn't have said I'll try, because I did provide a patch. :)

Michelle’s picture

Status: Needs review » Reviewed & tested by the community

Sorry about the mixup. I had the patch scrolled off the screen, left for a while, then came back and read the post, and totally missed there was a patch up there.

Ok, I confirmed the fatal errors without the patch, then applied the patch and tested the following:

* User created menu - Edit block / Edit menu links both work.
* Core provided menu - Edit block / Edit menu links both work.
* Devel provided menu - Edit block / Edit menu links both work.
* Who's online block - Edit block works. No edit menu links as expected since it isn't a menu.

Looks good to me. My only concern is whether or not this should be split into two issues, one to fix the fatal errors which is a bug and one to add the menu links, which is a feature. I'll leave that up to you/the maintainers, though.

mrjmd’s picture

Old parent issue is Closed (Fixed), changing parent to META issue for next release.

japerry’s picture

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

Naw both issues here work fine. Looks good to me, and fixed!

  • japerry committed 216da0e on 7.x-3.x authored by gmclelland
    Issue #2381319 by gmclelland, Michelle: Refactor "Edit block" and add "...

Status: Fixed » Closed (fixed)

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