1

I have a view which I want to output as plain raw data (no html tag, no div, nothing, just the view content as text). I managed to override html.tpl.php, and page.tpl.php templates, but i still have some default markup... I get this:

<div class="region region-content">

And don't know how to get rid of it. I guess the region.tpl.php template is responsible for this, but how could I override it just for that given view (which has an internal path: user-export).

I tried region--user-export.tpl.php but my template is not seen by drupal. Do I need to use a template suggestion ?

Thanks in advance!

EDIT: I found a solution. Probably not the cleanest way but it works. I created a "blank" theme, where I overrode region.tpl.php by creating a file named region.tpl.php and stripping all divs and classes from it. I then downloaded the "Page Theme" module and set the template to "blank" for the view url. And that was it. my view got displayed with no wrappers, no divs, just plain text.

1

2 Answers 2

1

I would personally not use the method you currently have as it would seem to be overkill.

You can use your template.php file of your theme to set a different template file to use under your given conditions.

Like this, in your theme's template.php file (Note: this is adapted from the Zen theme):

/**
 * Preprocess variables for region.tpl.php
 *
 * @param $variables
 *   An array of variables to pass to the theme template.
 * @param $hook
 *   The name of the template being rendered ("region" in this case.)
 */
function THEMENAME_preprocess_region(&$variables, $hook) {
  // Use a template with no wrapper for the content region on the path VIEWPATH.
  if ($_GET['q'] == 'VIEWPATH' && $variables['region'] == 'content') {
    // Allow a specific template to override the content region.
    // The template file will be region--no-wrapper.tpl.php
    array_unshift($variables['theme_hook_suggestions'], 'region__no_wrapper');
  }
}

Then to your theme add the region--no-wrapper.tpl.php file with the wrapper markup stripped out.

Then clear the drupal cache.

0

If you are using views you can find out what the name of the template should be looking under the following in views ui:

Advanced > Theme : information

1
  • Hi, basically, the "toppest" template that we can override with this is "Style". The region template is higher... I found a solution though, I'll edit my question for those who are interested. Thanks for your help :)
    – gkpo
    May 29, 2012 at 17:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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