If you are displaying a view such as “frontpage (default)” that uses a row style of “node” and the Statistics Module is enabled with the "post access counter" and the user does not have the "post access counter" permission the “link type="text/css" rel="stylesheet" media="all" href="/sites/all/modules/views/css/views.css?J" ” line is not included in the header.

For someone without the post access counter permission the node is displayed (without the post access information) but without the default formatting provided by views.css. I have tried this with multiple themes including Garland with the same results.

It seems that if any part of the view is displayed the views.css style should be added to the page.

Comments

merlinofchaos’s picture

Status: Active » Closed (works as designed)

I cannot reproduce this.

Note that views.css is added only if 1) the user has permission to see the administer links, or 2) an exposed form is being rendered. Perhaps it the statistics correlation you see is just coincidence.

bigbaldy’s picture

Thank you for the response.

When I was initially creating a front page not having views.css available for anonymous users was producing a different output than when I was logged in as an administrator. A little css tweaking of the template fixed the problem. I had originally thought that some of the css code in views.css was being used for the default display of the created view. You cleared that up by identifying views.css as css for the admin part of views. I'm not sure what the correlation between views.css showing up for anonymous users when I had the statistics module off and not when it was on. But, since views.css is only for admin it becomes the themes responsibility for the created view anyhow.

Thanks for creating an invaluable module. Without it a number of projects that I am working on would be impossible.

merlinofchaos’s picture

Well, it's for admin (it controls the hover links) and it's also for the exposed filters, so certainly that could be an issue. But it does not sound like you were using them. I agree, it's difficult to tell why you were experiencing a difference.

emilymoi’s picture

Hello,

I came to this thread because I was searching for information as to why I am getting a border-top on my grid tbody only for anonymous users.

If it is true merlin, that views.css is normally not included then perhaps the following block should be relocated?

/* Remove the border on tbody that system puts in */
.views-view-grid tbody {
border-top: none;
}

Thanks.

merlinofchaos’s picture

Status: Closed (works as designed) » Active

Ahh, yes, that probably should always be there. Or actually it should probably be in a css file that comes with the grid style.

3goose’s picture

This isn't related to the Post Access Counter, but seems similar enough to include here. I have a front page with 10 views embedded in the page-front template, but views.css does not load. However, if i put a views block into a region on that page, it does load.

It would be nice if views.css loaded on pages with only embedded views, but I don't understand what it would take to do that.

I don't think i'm doing anything wrong to cause it to not show up, but that's always possible too:)

Pasqualle’s picture

Re #6: I can confirm this behavior.

page-front.tpl.php

<head>
  <?php print $styles; ?>
  ...
</head>
<body>
  <?php print views_embed_view('myview') ?>
  ...
</body>

the reason is obvious. Calling drupal_add_css() from page.tpl.php has no effect as the $styles variable will not change..

jh3’s picture

I'm having this same problem when embedding views in my page.tpl.php file. The needed css and javascript are not being included when the view is embedded, but if it's an enabled block in the region everything works fine.

If anyone knows any sort of work around, it would be great know.

Pasqualle’s picture

if you know which css and js files are missing, then you can add them manually with *_preprocess_page() in template.php

for example adding views.css to front page:

function MYTHEMENAME_preprocess_page(&$vars) {
  if ($vars['is_front']) {
    drupal_add_css(drupal_get_path('module', 'views') .'/css/views.css');
  }
  // Reconstruct CSS and JS variables.
  $vars['css'] = drupal_add_css();
  $vars['styles'] = drupal_get_css();
  $vars['scripts'] = drupal_get_js();
}
dawehner’s picture

Thats cannot be called bug.

If you call views_embed_view in your page.tpl.php the $styles and $scripts variable is already rendered.
So drupal_add_css cannot add things additonal.

Pasqualle’s picture

bug or not, hopefully it will be fixed in Drupal 7 #469242: Move <head> outside page.tpl.php

jh3’s picture

This seems like a good idea, but a few bad things happen when I try and do this.

First, the site I am working on has over 30 style sheets loaded at one time. This means I am using this module to overcome the IE limitations when it comes to loading more than 30 style sheets.

Second, the views I am trying to embed in my page.tpl.php file are using the views rotator style. Since they are using this style/module, the views take advantage of the mains views.css file, the views rotator module css file, and there is jquery that the module uses as well.

When I attempt to embed the views without trying to use the *_preprocess_page() function the views don't load the necessary css and javascript in order for the style to work. So, your solution seemed like something that should have worked for me. This wasn't the case though. When I enabled the function and added a couple of drupal_add_css functions and a drupal_add_js function, these files were indeed included on the page. However, while using this preprocess_page function, once it rebuilds the $script and $style variables, it loads all of the css files differently. It loads them like it did before the IE Unlimited CSS module was enabled, which means the page totally breaks in IE.

The views still don't work either even while preprocessing what I think are the necessary files. I feel like the javascript needs to be included differently. When I view the source of a page when the view is loaded through the blocks module, the javscript on the page is contained in something like this: jQuery(Drupal.Extends{"code here;"});

If anyone knows of any workaround or something I'm doing wrong here, I'd appreciate the feedback.

Thank you.

atamanbasar’s picture

the same problem occurs for me, just i (admin) can see the chages of views.css. the only solution that i have found is giving permission to anonymous users "administer views" which can not be acceptable. So any ideas for this problem ?

atamanbasar’s picture

i have fixed my problem by upgrading the version of views to the last version

merlinofchaos’s picture

Status: Active » Fixed

Yes, latest Views includes views.css unconditionally. This problem should no longer exist.

Status: Fixed » Closed (fixed)

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