I have one view where I want to only output the actual output without any wrapping divs or spans. I've tried to do so by overriding the theme without luck. Anyone who has a good suggestion on how to do it?

Comments

dawehner’s picture

1) You could do this by using theming, and remove everything which is not needed from the template files.
For example the views-view.tpl.php would be reduced to:

<?php
// $Id: views-view.tpl.php,v 1.12.2.1 2009-06-02 19:30:40 merlinofchaos Exp $
/**
 * @file views-view.tpl.php
 * Main view template
 *
 * Variables available:
 * - $css_name: A css-safe version of the view name.
 * - $header: The view header
 * - $footer: The view footer
 * - $rows: The results of the view query, if any
 * - $empty: The empty text to display if the view is empty
 * - $pager: The pager next/prev links to display, if any
 * - $exposed: Exposed widget form/info to display
 * - $feed_icon: Feed icon to display, if any
 * - $more: A link to view more, if any
 * - $admin_links: A rendered list of administrative links
 * - $admin_links_raw: A list of administrative links suitable for theme('links')
 *
 * @ingroup views_templates
 */
?> 
<?php if ($rows): ?>
  <?php print $rows; ?>
<?php elseif ($empty): ?>
   <?php print $empty; ?>
<?php endif; ?>
<?php /* class view */ ?>
NeoID’s picture

Hi, thanks, but I've tried that, but it's still printing the divs (after changing the theme in views and clearing the cache) it's still adding the span and div around the output... :/
<?php print $rows; ?>still prints div and spans...

Output now:

<div class="views-field-field-background-image-fid">
<span class="field-content">sites/..../files/wallpapers/wallpaper1.jpg</span>
</div>

I need:
sites/..../files/wallpapers/wallpaper1.jpg

dagmar’s picture

@NeoID: Please take a look at #269319: How to theme CCK field with a content-field-my_field.tpl.php file you need to change something that is out of the scope of views.

seutje’s picture

NeoID’s picture

@seutje: It still doesn't remove the innermost div and span...

seutje’s picture

guess u also have to override content-field.tpl.php

merlinofchaos’s picture

Status: Active » Closed (won't fix)

"The innermost div and span"

Since none of us are looking at your content, we have no idea of knowing which div and span this actually is. There are several potential themes that you need to override in order to remove all markup. Please see the theme: information page for which ones you can theme in Views. If those theme functions don't do it, then the markup isn't in Views or cannot be overridden.

NeoID’s picture

Therefor I pasted my current output in post 2.
What I struggle are those wrappers:

<div class="views-field-field-background-image-fid">
<span class="field-content">sites/..../files/wallpapers/wallpaper1.jpg</span>
</div>
merlinofchaos’s picture

views-field is provided by the field template within views. Override views-field.tpl.php to get rid of that.
field-content is provided by CCK. You'll have to check there for solutions.

NeoID’s picture

Status: Closed (won't fix) » Fixed

Thanks a lot merlinofchaos and all others helping me out!
After creating three themes overrides it finally works! :)

seutje’s picture

u might be interested in the Mothership basetheme, it's pretty hardcore at removing wrappers

Status: Fixed » Closed (fixed)

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

stewie32’s picture

How did you solve this problem. I am having the same issue

NeoID’s picture

@Stewue32:

I used the following in my tpl.php file for the view:
<?php if ($rows): ?><?php print $rows; ?><?php elseif ($empty): ?><?php print $empty; ?><?php endif; ?>

Hope that helps. :)

stewie32’s picture

Status: Closed (fixed) » Active

@NeoID:

Thanks for the quick response. It's still not working for me though. I copied the views-view-field.tpl.php and renamed it appropriately views-view--view name.tpl into my theme's folder and replaced its code with the code you recommended. I also tried copying over the views-view-unformatted.tpl.php (because my view is styled unformatted) and doing the same, but it still shows the div span wrapper tags.

Am i over writing the wrong views.tpl file?

NeoID’s picture

@stewie32: Try this (in this example my view is 'user_wallpaper'):

Display output: views-view--user-wallpaper.tpl.php
<?php if ($rows): ?><?php print $rows; ?><?php elseif ($empty): ?><?php print $empty; ?><?php endif; ?>

Style output: views-view-unformatted--user-wallpaper.tpl.php
<?php foreach ($rows as $id => $row): ?><?php print $row; ?><?php endforeach; ?>

Row Style: views-view-fields--user-wallpaper.tpl.php
<?php foreach ($fields as $id => $field): ?><?php print $field->content; ?><?php endforeach; ?>

stewie32’s picture

Status: Active » Fixed

Thank you so much. works like a charm.

Status: Fixed » Closed (fixed)

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

ClaudeS-1’s picture

I found this documentation which helped me - I'm trying to remove formatting from a field that isn't in a view, but just in a node/page template.

http://api.drupal.org/api/drupal/modules--field--field.module/function/t...

passportgeek’s picture

Title: Remove all the wrapper divs around content » how to remove single span from <span> <span>Quick reply</span> </span> in drupal forum