I figured I should start a new thread since the last d7 patch has been committed and the 7.x-dev version is out. This extends the module further making sure to cleanup after itself when a node is deleted, and if a node type has a default panel configured the settings page for a node will allow a user to reset the panel display to the default display for that node type

Comments

dww’s picture

Status: Needs review » Needs work

Thanks for working on this. However, it's not immediately obvious what these two things have to do with each other. Why are they in the same issue and patch? That just makes it harder to understand what's changing and why.

Furthermore, ever since D6, the suggested way to have different buttons with different results is to register separate submit handlers for each button. Inspecting $form_state['clicked_button']['#value'] isn't The Right Way(tm) to do this.

cangeceiro’s picture

The delete hook was added to make reseting the panel display possible. basically resetting just removes the display and the reference to the display in the database so that it falls back on rendering using a default. So that is why they are both wrapped into this patch. I havent seen any examples of using separate submit handlers but I am open to reworking this to The Right Way™.

dww’s picture

Thanks for the explanation about how delete and reset are intimately tied, that helps!

Re: separate submit handlers for different buttons. Check out node_form() (in either D6 or D7 -- I linked to D6 but the same works in D7). Let me know if that's clear enough, or if you need further direction.

Cheers,
-Derek

cangeceiro’s picture

StatusFileSize
new3.26 KB

Ah yes, that helps greatly. here is an updated patch using #submit for the reset

dww’s picture

Status: Needs work » Needs review

Looks great. Any chance you can provide a D6 backport (e.g. without the DBTNG notation)? Thanks!

dww’s picture

Status: Needs review » Fixed

I had to re-roll this a bit due to some other fixes I pushed to the 7.x-1.x branch, although I mostly got that working with a bit of Git treachery -- there was only 1 hunk that conflicted. However, this visually looked fine, and I don't have a D7 test site yet (and apparently no one else did, either -- see #1100922-28: Drupal 7 port of Panelizer), so I just went ahead and committed and pushed my re-roll:

http://drupal.org/commitlog/commit/18014/54475a0f80973c633b223096612e3c6...

However, unfortunately, this didn't apply at all to the end of the 6.x-1.x branch, even with various tricks (maybe my Git fu isn't strong enough yet, but I think it's due to divergences from the D7 port). :( So, I manually backported the fixes, including undoing the DBTNG query, using hook_nodeapi() instead of hook_node_delete() (which doesn't exist in D6), etc. The D6 version I could actually test, and I uncovered a few bugs. When you tried to delete a node, you got an undefined call to panelizer_load_node_panelizer() since includes/node.inc wasn't loaded. Also, the drupal_set_message() when you reset the panel was missing a trailing period. But with all that fixed and working, I committed and pushed it to 6.x:

http://drupal.org/commitlog/commit/18014/a285cbee85f413b40c515a1a174b460...

Then I forward ported my bug fixes to 7.x:

http://drupal.org/commitlog/commit/18014/518ed126a4ca5cd9d2e3b7adf989ff0...

So, unless the D7 version is totally broken (entirely possible), let's call this fixed.

@cangeceiro: Thanks! This is a good change...

dww’s picture

Version: 7.x-1.x-dev » 6.x-1.x-dev
Status: Fixed » Needs work

Whoops. Earl had to revert part of this patch:

http://drupal.org/commitlog/commit/18014/fb0500c91b00b6c013237481fca57ae...

That probably means that the "Panelize it!" button doesn't work in the 6.x-1.x branch right now, either.

dww’s picture

StatusFileSize
new1.04 KB

Yeah, the attached patch gets the "Panelize it!" button working again, but then things get a bit wonky when you try to do the reset case. :( I need to break for dinner, so I don't have time to clean this up, but it'd be great if cangeceiro could take another stab at this issue to make sure it works properly and doesn't break anything else. Thanks.

cangeceiro’s picture

StatusFileSize
new919 bytes

This patch fixes the "panelize it" button on d7. This also gives the reset button for a panel that has been panelized with or without a default panel configuration.

cangeceiro’s picture

Status: Needs work » Needs review

status change

merlinofchaos’s picture

Ok, I have to revert this patch *again*.

Let me explain. There was some pretty serious ignoring of how I'd set this up.

Panelizer is intended to be able to panelize anything. Right now it only panelizes nodes, and I think that's leading to the confusion.

Stuff in common.inc is common functionality. These forms are re-used in a LOT of places. The reasons they were written the way they are is so that they can be reused.

This patch rather unfortunately removed the reusability by hardcoding submit logic directly into the form, and worse, it actually hardcoded $node into a form in common.inc. Unfortunately, at the time dww was asking me questions about this, I was trying to pay attention but I was busy, and I didn't go refresh myself on the architecture.

I have to roll back this feature and return the form to its pristine "I don't know a thing about nodes" state.

I've added a comment to the doxygen about the form

That form is used both when editing a panelized node, and when editing a default panelized node. It can't make assumptions. In the future, that form will be used when editing a panelized user, and the default for a panelized user as well.

merlinofchaos’s picture

Status: Needs review » Fixed

I re-implemented the reset button. I tested it on D6 and cherry-picked it to D7. I also committed cangeceiro's fix for the panelize it form. I think that completes the issue.

I admit to not testing either on D7.

damienmckenna’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev

The reset button shows, but the panelizer_settings_form_reset() callback function doesn't exist in either the D6 or D7 branches.

damienmckenna’s picture

Status: Fixed » Needs work

If panelizer_settings_form() is supposed to be generic, wouldn't it be better for it to *not* define a menu callback but maybe accept that from the calling function, e.g.:

function panelizer_settings_form(&$form_state) {
...
  if (!empty($form_state['reset callback'])) {
    $form['reset'] = array(
      '#type' => 'submit',
      '#value' => t('Reset to default'),
      '#submit' => array($form_state['reset callback']),
      '#reset' => TRUE,
   );
  }

and then:

function panelizer_default_settings_page($type, $key, $name) {
...
  $form_state = array(
    'panelizer' => &$panelizer,
    'no_redirect' => TRUE,
    'reset callback' => 'panelizer_default_settings_reset',
  );
..
}

/**
 * Delete a panelizer node panel from the database
 */
function panelizer_default_settings_reset(&$form, &$form_state) {
  $panelizer = $form_state['panelizer'];
  if (!empty($panelizer->did)) {
    panels_delete_display($panelizer->did);
  }
  db_delete('panelizer_defaults')
    ->condition('pnid', $panelizer->pnid)
    ->execute();
}
damienmckenna’s picture

Status: Needs work » Needs review
StatusFileSize
new1.39 KB
new1.39 KB

Here's a quick patch to add a reset button for the content type settings page, one patch for each of D6 and D7.

merlinofchaos’s picture

Status: Needs review » Fixed

Committed to both branches.

Note that ot get the button to show up I had to add $form_state['reset button'] => TRUE

Status: Fixed » Closed (fixed)

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

pverrier’s picture

I'm using the Drupal 6 version (6.x-1.0-beta1), and have been wondering why I had no way to revert a local node Panelizer settings to the defaults...
This has been solved in #16 (september 2011) and commited in dev, but the last release for D6 remains older (2011-Feb-26).
Please could you release a beta 2 version with these latest devs? Thanks!

neclimdul’s picture

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

Woops, db_delete doesn't exist in d6.

neclimdul’s picture

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

pushed. back to fixed.