When you assign a CSS ID, custom CSS code or select a custom display renderer (e.g. IPE) to an entity bundle's default display settings, those values are not used for the display of the individual entity object nor are they copied over when that entity object's Panelizer settings are edited.

Update:

There are a few parts to this:

CommentFileSizeAuthor
#10 panelizer-n1841262-10.patch1.86 KBdamienmckenna

Comments

tchopshop’s picture

I guess this refers to the fact that I could not apply a css class or ID to a panelized teaser display. I really need this though. I need to apply a class to each one of my list of default layouts, so that I can further style them.

mediaformat’s picture

I was able to apply custom classes to the layouts, regions, etc in panels. admin/structure/panels/layouts

Laurent Ren’s picture

I got the same problem.

With existing entity, when I modified some options (CSS ID, link to entity, etc...) of the default display (by "default" I mean displays configurable in /admin/config/content/panelizer), these options were not used/copied to the display of the existing entity.

When creating new entity or reset displays of existing entity, these options were copied/used.

In order to resolve this problem, I added this, in PanelizerEntityDefault.class.php, in the hook_entity_load and at line ~841 :

                $context = array(
                    'panelizer_defaults' => $panelizer_defaults,
                    'view_mode' => $view_mode
                );
                
                drupal_alter('panelizer_entity_default', $entity, $context);

after :

if (!empty($entity->panelizer[$view_mode]->did)) {
            if (empty($displays[$entity->panelizer[$view_mode]->did])) {
              // Somehow the display for this entity has gotten lost?
              $entity->panelizer[$view_mode]->did = NULL;
              $entity->panelizer[$view_mode]->display = $this->get_default_display($bundles[$entity_id], $view_mode);
            }
            else {
              $entity->panelizer[$view_mode]->display = $displays[$entity->panelizer[$view_mode]->did];
            }
          }
          else {
            if (!empty($panelizer_defaults[$entity->panelizer[$view_mode]->name])) {
              $entity->panelizer[$view_mode]->display = $panelizer_defaults[$entity->panelizer[$view_mode]->name]->display;

Then in my custom module :

function mymodule_panelizer_entity_default_alter(&$entity, &$context)
{
    $panelizer = $entity->panelizer[$context['view_mode']];
    if(isset($context['panelizer_defaults'][$panelizer->name]))
    {
        $default = $context['panelizer_defaults'][$panelizer->name];
        
        $attributes_to_copy = array(
            'no_blocks',
            'css_id',
            'css',
            'contexts',
            'relationships',
            'css_class',
            'title_element',
            'link_to_entity',
            'extra'
        );
        
        foreach($attributes_to_copy as $attr)
        {
            if(isset($default->$attr))
            {
                $panelizer->$attr = $default->$attr;
            }
        }
     
        $entity->panelizer[$context['view_mode']] = $panelizer;
    }
}
damienmckenna’s picture

There's also a generic problem that the CSS is never reloaded.

damienmckenna’s picture

damienmckenna’s picture

Just ran into this. Argh.

damienmckenna’s picture

Assigned: Unassigned » damienmckenna

Working on this tonight.

damienmckenna’s picture

Title: Settings (renderer selection, CSS ID, CSS code) added to the default is not used » Load configured settings (renderer selection, CSS ID, CSS code) when a display is used
Issue summary: View changes
Related issues: +#1965148: Load the full Panelizer default object

Ok. This is definitely weird.

It seems that this is being caused by the fact that when the entity is saved, the full Panelizer record is saved, including the then current values for these settings; this can be confirmed by checking the {panelizer_entity} table. If the default is updated these settings are not reloaded, Panelizer just uses whatever values had been saved in the {panelizer_entity} table. However, when the entity is updated it then also updates all the Panelizer settings to the latest versions.

Because we're already dealing with not saving the defaults in #1965148: Load the full Panelizer default object, lets focus this issue on making sure Panelizer properly loads all of the settings from the named display configuration, not the {panelizer_entity} table.

damienmckenna’s picture

Issue summary: View changes
damienmckenna’s picture

Assigned: damienmckenna » Unassigned
Status: Active » Needs review
StatusFileSize
new1.86 KB

The problem was rooted in PanelizerEntityDefault->hook_entity_load(). The way it worked, it checked different scenarios to see what display to use, in the end it would assign the bare $display variable from the configured default for any display that had one, but didn't load the other settings. I've updated it to load $contexts, $css, $css_class, $css_id, $display, $extra, $link_to_entity, $no_blocks, $pipeline, $relationships, $title_element.

This appears to resolve the problem in my (albeit limited) testing. It adds a little more processing during hook_load_entity, but I think it's minimal.

Status: Needs review » Needs work

The last submitted patch, 10: panelizer-n1841262-10.patch, failed testing.

damienmckenna’s picture

Version: 7.x-2.x-dev » 7.x-3.x-dev

I never noticed this was on the 7.x-2.x branch. Gah.

damienmckenna’s picture

Status: Needs work » Needs review
damienmckenna’s picture

10: panelizer-n1841262-10.patch queued for re-testing.

joel_osc’s picture

Patch seems to be working well for me, thanks!!!

drupov’s picture

Refering from https://drupal.org/comment/8478787#comment-8478787

Panelizer was using the saved values from table "panelizer_entity" and did not respect views contexts that were loaded for that view mode. Patch from #10 solved that for me.

Thanks @DamienMcKenna for pointing me to the right issue!

fago’s picture

I've implemented a fix at #1965148-25: Load the full Panelizer default object which should cover this problem as well - please have a look and test.

scottalan’s picture

@fago

Should the reference to your fix be at #1965148-25: Load the full Panelizer default object?

edt: sorry, just realized how the short-link works. I see you were referencing: https://drupal.org/comment/8492051#comment-8492051. I misunderstood and thought that was a reference to a node (8492051).

fago’s picture

yes, I updated the link to avoid further confusion ;)

drupov’s picture

With both patches - #10 from here and https://drupal.org/comment/8492051#comment-8492051 - I cannot apply the value I enter in the "CSS ID" field on the Settings page to the panelized entity. It simply is not part of the html.

What I enter in "CSS class" field gets rendered though.

damienmckenna’s picture

Status: Needs review » Fixed

After some more testing this is good for now. Committed.

damienmckenna’s picture

Scrap that.

Yes, #1965148: Load the full Panelizer default object will replace this.

Status: Fixed » Closed (fixed)

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