Views Theming

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
rpeters's picture

How do I theme a particular view. I want to remove the submitted by on a particular view, but still keep submitted by on the conetnt type.

Comments

Hi Robert, Usually you have

design.er's picture

Hi Robert,

Usually you have to override your $node.tpl.php. It might look like this:

<div id="node-<?php echo $node->nid; ?>" class="node<?php if ($sticky) { echo ' sticky'; } ?><?php if (!$status) { echo ' node-unpublished'; } ?>">

<?php if ($teaser OR $page == 0): ?>

  <h2><?php echo $title; ?></h2>

  <?php echo $content; ?>

<?php else: ?>

<?php if ($submitted): ?>
  <span class="submitted"><?php echo $submitted; ?></span>
<?php endif; ?>

  <?php echo $content; ?>

<?php endif; ?>

</div>

Any reason

DeNelo's picture

Hi,

I'm new. Is there any reason that you close and reopen the php code all the time instead of writing a single php block, mixing the html into the code?

Curiously,

And you would override it

linclark.research's picture

And you would override it using the following naming convention: node-view-VIEWNAME.tpl.php

Where VIEWNAME is, of course, your view's name.

you could also do it quick

wodenx's picture

you could also do it quick and dirty with css - something like:

.view-VIEWNAME .submitted {
display: none;
}

though the specific selectors might depend on your theme and/or views configuration.

why open and close Php tags and use HTML saperate

Narek's picture

Because if you don't open and close your php tags, then you need to echo/print HTML codes, so if you echo those then you need to Encode the HTML codes because of HTML tags, so it is more easier to just open and close php tags, and write the HTML codes between those.

i think you looking in the

SKAUGHT's picture

i think you looking in the wrong place. the code sample above is a 'node template', not a 'view'. the correct template trial to follow is:

node.tpl.php
node-news.tpl
node-teams.tpl
etc

the second piece is the machine name of your content-type.

You can remove the submitted by information without theming

danreb's picture

Just go to theme configuration page in -> admin/themes/settings

This is the theme configuration page and just un-check the content type you don't want to show a submitted by information,

That is under the "Display post information on" configuration box.

Views Developers

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: