In my page.tpl.php I'm doing this to display one of my view:

print views_embed_view('teaserview', 'default');

That gives me the following html output:

<span thmr="thmr_10">
<div class="view view-teaserview view-id-teaserview view-display-id-default view-dom-id-e051ba535ce9aac6cd9a0d564b3dbb29 contextual-links-region">
    <div class="contextual-links-wrapper">
        <span thmr="thmr_16">
        <ul class="contextual-links">
            <li class="views-ui-edit first last"><span thmr="thmr_17"><a href="/kbi/admin/structure/views/view/teaserview/edit/default?destination=node/3">Edit view</a></span></li>
    <div class="view-content">
        <span thmr="thmr_15">
        <div class="views-row views-row-1 views-row-odd views-row-first views-row-last">
            <span thmr="thmr_14">
            <span thmr="thmr_11"><span thmr="thmr_12"><span thmr="thmr_13"><img src="" width="1029" height="308" alt="" /></span></span></span></span>

But the only thing that I really need is

<img src="" width="1029" height="308" alt="" />

Is there a possibility to modify the views_embed_view call so that I get only the needed data?

There would be the possibility to modify all the views .tpl.php files but I hope there's an easier way to do this.

I also read about the semantic views module but I didn't understand how to configure my view with it so that i get only the needed markup as output. it didn't seem to have any effect.

  • Which version of Drupal/Views are you using? Views 3 has settings per view for this, I'm sure they'll pass over into a programatically embedded view.
    – Chapabu
    Mar 15, 2012 at 8:55
  • i'm using views 3... which settings are you refering to?
    – toxinlabs
    Mar 15, 2012 at 12:22

4 Answers 4


If you go into the view thru the Views UI, and look at the fields, you can configure/remove the wrapper html from the field by selecting none for the wrapper of the field, and that should take a lot, if not all, of the html away that you don't want. Also, if you go into the views admin screen and go to tools, you can check the "Do not show hover links over views" which should remove the first edit portion of all of your views when looked at via an admin type account as well.

If the above doesn't take away all the html you want, you can either modify the templates as you mentioned above, or use something like this instead of views_embed_view:

$view = views_get_view('teaserview');
$display_id = 'default';

which will execute but not display the view ... but will create a $view->result which is an array of row objects basically, so you could then go in there and print out whatever you wanted.

To find out what is in there, throw in a

drupal_set_message('<pre>' . print_r($view->result, true) . '</pre>');

and you'll see what you can work with.

PS Once you have this working, I would put it in a preprocess hook and assign this output to a variable instead of putting any/all of this code in your page.tpl, too...

PPS I also am assuming you know that the Theme Developer module is throwing a lot of html in there as well (all those thmr='s as such).

  • you're right, some stuff i couldn't get rid of was from theme developer ... damn ;)
    – toxinlabs
    Mar 15, 2012 at 17:40
  • she can be a cruel mistress
    – Jimajamma
    Mar 15, 2012 at 18:02
  • true :). just getting started with drupal a LOT to learn.
    – toxinlabs
    Mar 16, 2012 at 1:15

i think i have it running ok now, you tell me if this is the most elegant way ;)

i copied the views-view--[ViewName].tpl.php to my theme folder and made the following changes:

<div class="<?php print $classes; ?>">     // delete this line
  <?php print render($title_prefix); ?>
  <?php if ($title): ?>
<?php if ($header): ?>
    <div class="view-header">   // delete this line
      <?php print $header; ?>
    </div>                      // delete this line
  <?php endif; ?>
<?php if ($rows): ?>
    <div class="view-content">  // delete this line
      <?php print $rows; ?>
    </div>                      // delete this line
  <?php elseif ($empty): ?>

and then i made some adjustments in the view editor (i installed the semantic views module):

Format: Semantic Views

Show: Semantiv Views: Fields

then in the field settings:

multiple field settings

[x] display all values in the same row

[x] simple seperator (and then just empty the seperator text field so that no seperator is inserted in the output)

rewrite results:

[x] strip HTML tags

[x] remove whitespace

Preserve certain tags: (in my case i'm displaying image fields, so depending on the content of your fields this may differ)

-> this gives me a clean

<img src="" width="1029" height="308" alt="" />

at the end.

  • all is well and good if it is easy to understand on your own site, but I would instead of editing views-view.tpl.php, which [ae]ffects all views, I'd edit views-view--VIEWNAME.tpl.php or views-view--VIEWNAME-DISPLAYNAME.tpl.php instead.
    – Jimajamma
    Mar 15, 2012 at 19:30

You should try the Fences module, an alternative to Semantic Views

Fences is a an easy-to-use tool to specify an HTML element for each field. This element choice will propagate everywhere the field is used, such as teasers, RSS feeds and Views. You don't have to keep re-configuring the same HTML element over and over again every time you display the field.

  • fences does not work with views and semantic views are too much OP for the task. Also, they do not strip the HTML but modify it. Aug 29, 2016 at 8:48

You can do it by changing the views Style settings for that particular field name . Check on the "Customize Field HTML" and select 'None' from the select options.

  • That's not it does as asked by OP. Aug 27, 2016 at 8:32

Your Answer

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

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