There is a small todo in views_plugin_display_system::execute, because some css is added.

What about using a preprocess_views_view and check for the used display.

Comments

dawehner’s picture

Status: Active » Needs review
StatusFileSize
new1.13 KB

This works fine for me

Status: Needs review » Needs work

The last submitted patch, 1603828-css-todo.patch, failed testing.

sun’s picture

Apparently, the testbot disagrees ;)

Does Views provide no way to do this from within the display handler? Ideally, I'd think that this should be part of the render array being generated and also use #attached, so other/custom modules and themes can adjust it when necessary.

dawehner’s picture

Which render array ... views still builds a lot of with strings, so for example display::render() should return the rendered string.
There are several reasons for that. First merlinofchaos has a strong opinion against it, and second this would have required at least some breaking of template files from d6 to d7. Funny enough a lot of people complained, quite some people tried to convert it and all of them failed.

A workaround seems to me to add something to the view object, and support it in views itself, though this is still inconsistent.

damiankloip’s picture

If everyone agrees, I think that at best this issue should be marked as postponed? This would need a patch to go into views for another implementation that is better than the current one.

sun’s picture

Our current code seems to fail to load the CSS for the preview in the Views admin UI, so if there is any approach that makes that work, then I think we should go for it.

damiankloip’s picture

sun, leave it with me. I will see what we can do and report back :)

sun’s picture

Title: Replace todo about adding css in views_plugin_display_system::execute » admin_views.css is not loaded for Views live preview
Category: task » bug

Let's clarify this issue a bit.

damiankloip’s picture

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

ok, if we are definitely going to pursue this one. The only other way I can think of doing this is in this patch. If we override the preview() method for the display plugin we can add our css inline.

damiankloip’s picture

StatusFileSize
new1.1 KB

But without the two ; in the render function :)

sun’s picture

ugh. ;)

If there's really no better support in Views for adding JS/CSS to the live preview, then I'd say let's rather ignore the problem... :-/

The first hunk (as well as removing the @todo) would make sense though.

damiankloip’s picture

StatusFileSize
new704 bytes

I know :/ It's certainly not ideal (or even close). I just thought I would propose the only option I could think of and see what the consensus was. That's why I didn't voice an opinion about it in #9. This approach isn't that nice, you're right ;)

I am happy to close this too as it's not a deal breaker imo.

Shall we just go with this in that case?

sun’s picture

Status: Needs review » Reviewed & tested by the community
damiankloip’s picture

Status: Reviewed & tested by the community » Fixed

Committed to 7.x-1.x

Status: Fixed » Closed (fixed)

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