I have been trying to apply a custom classes to ds_content layouts, eg grid-3-item, grid-2-item, grid-1-item. This has not been working for the case where I have a single ds_1col layout as there are no "group" wrapper divs to accept the classes. If I use two (or more) column layouts then the custom classes come through OK as the group wrappers exist. However, these wrappers do not exist for ds_1col layouts. The result is that the custom class doesn't make it through to the HTML.

I have hacked around this by injecting the classes into the parent if it is "ds_content" layout. eg. in ds_entity_variables()

if (!empty($layout['settings']['classes']['ds_content'])) {
  $vars['classes_array'] += $layout['settings']['classes']['ds_content'];
}

I think that we should be able to get custom classes into one col layouts. This may not be the way to do it though. Are there better/alternative ways to do it?

Comments

murrayw’s picture

StatusFileSize
new1.07 KB

And here is the little patch to handle this.

swentel’s picture

Status: Active » Postponed (maintainer needs more info)

I'm not sure if we should handle this in ds_entity_variables(). What if someone else makes it's own single column layout with a different key, then this solution obviously won't work. A more 'works-for-all-single-column-templates' solution would be to add some sort of key to the layout definition that tells us to wrap those classes.

The fastest alternative is to copy the template file to your theme and just change the template file to your needs to make this work. We never had this use case before, so if we would have this, we'd probably put this in our base theme so we never have this problem anymore. Would that be enough for you as well ?

murrayw’s picture

Thanks for the reply swentel. I appreciate your time and effort.

I agree that my solution is flakey, especially if someone else comes along with their own single column layout. The code could be rewritten I guess to test for their only being a single layout, rather than driving it off the ds_content key. However, this improvement would still lead to a mismatch - I really want to be able to give the whole layout its own class, rather than to apply it to different groupings of fields.

It may not be a use case that you have seen before, probably because I am trying to build a system which will allow for the future creation of ds layouts by site builders which will work in nicely with grid layouts WITHOUT having to change the CSS in the theme. ie. I would like to say, "this-layout-is-a-grid-x". The theme can then be driven from this super class, rather than off the individual layouts which are numerous.

The best solution for me would be to have a "Layout classes" field in the "Custom wrappers" tab. This would achieve exactly what I am after. I'm not sure if this is what you meant by putting it in your "base theme"? I'm away for the next few days but wouldn't mind writing a "layout classes" patch to handle this. Does this sound like a reasonable approach?

swentel’s picture

I think that sounds reasonable yes - if you have a patch I'll definitely review it!

kclarkson’s picture

Status: Postponed (maintainer needs more info) » Active

I can also confirm this issue. Works for 2-Col displays but not on 1-Col.

swentel’s picture

Title: ds_content classes » Support for 1 column layouts
Category: bug » feature
aspilicious’s picture

Status: Active » Fixed
kclarkson’s picture

So does this mean that it has been committed ? Because the last update on the Dev version I am seeing is 8/12

Thanks,

swentel’s picture

yes, but dev version are only rebuilt every 12 hours.

Status: Fixed » Closed (fixed)

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

murrayw’s picture

Yo aspilicious - thanks so much. I can't tell you my surprise when I saw those classes in there after a recent update. Thanks so much for scratching the itch I didn't have time to do. Your patch works for me and will make my life much easier - and CSS much simpler. Cheers!

zmove’s picture

Hi,

Tried the patch. It add the 2 classes to the layout div, that sounds incorect to me.

We should have 2 level of wrapper, one for the content, one for the wrapper. Exactly as the others more columns templates. Like this, we could setup classes and tags like the others.

For example that patch doesn't correct the issue if you set different tags for layout and for content (for example "header" for layout and "aside" for content.

zmove’s picture

StatusFileSize
new421 bytes

Worked on that problem. I think the module code is correct. I would modify the 1 column template file instead. Here is attached file.

With that file, you can continue to setup layout and ds_content separately, like the others. It just add one level of wrapper but it's by design.

Maybe create 2 versions of 1 column layout ? This one to have a full controls over the content classes (for example, for me, I needed this one to put thumbnails into span3 content with twitter bootstrap) and the actual one, the light version that break admin configuration but that save one div.