0

I am using the views-field-view module to output the number of teachers I have in each school, so it's just a plain number. The parent view that this child view is embedded in is a table with some other information (see screenshot).

Is there a way for me to remove any and all formatting from the child view so that the final output looks like it's all coming from one view? As you can see in the screenshot, there is some misalignment with the numbers, and there is also a weird line above the numbers coming from the embedded view.

http://screencast.com/t/cFi0ctcZS

Thanks in advance!

Lukas

2

Yes, you have to override the templates of the child view to remove the markup you don't want.

You will might need to override (in order of how likely it is you need to override them in some way):

views-view.tpl.php
views-view-unformatted.tpl.php (if you are using the unformatted style. Otherwise whichever style template is relevant to your view)
views-view-fields.tpl.php

You need to find where the unwanted line is coming from in the markup/css and then find the template that markup is printed in, then override that template and remove the offending markup.

Alternatively you can likely style it out with css but I would favour the template override option.

2
  • You can also remove a lot of markup by unselecting the Provide default field wrapper elements checkbox in the Settings for the fields on the Views UI page: If not checked, fields that are not configured to customize their HTML elements will get no wrappers at all for their field, label and field + label wrappers. You can use this to quickly reduce the amount of markup the view provides by default, at the cost of making it more difficult to apply CSS.
    – Jimajamma
    Mar 15 '14 at 13:56
  • Yeah good idea. Then the main thing you might have to worry about is views-view.tpl.php and hopefully don't have to worry about the other templates.
    – rooby
    Mar 16 '14 at 0:55
1

If you do not need ANY CSS rule at all from the view module, you will find more effective to just disable the CSS file by adding this function to your theme template.php file:

function MYTHEME_css_alter(&$css) {
 //Define an array with the path to the CSS file and a boolean flag
 $exclude = array(
  /*
   * It is possible to define more exclusions by adding more definitions
   * in this zone following the template:
   * 'path/to/css/file.css' => FALSE,
   */
  'sites/all/modules/views/css/views.css' => FALSE,
 );

 //Then array_diff will clean up the unneeded files 
 $css = array_diff_key($css, $exclude);
}

You can add any CSS file from the system by just specifying the path from the root folder, for instance this will remove the default system CSS file for the module user:

'modules/user/user.css' => FALSE,

This will reduce the bandwidth consumption and generate smaller files if you use the compress CSS files option.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.