Take the 2-minute tour ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

I've defined a view with the CCK and View modules. I have two ways for printing the result:

  1. As node content 2 As fields content

If I choose node content, I need to choose the view mode, which by default allows to choose between teaser, and rss (among others). How do I create a new custom view mode?

If I choose fields content, I see the following data, under theme information.

  • Display output: views-view.tpl.php, views-view--frontpage.tpl.php, views-view--default.tpl.php, views-view--default.tpl.php, views-view--page.tpl.php, views-view--frontpage--page.tpl.php

  • Style output: views-view-unformatted.tpl.php, views-view-unformatted--frontpage.tpl.php, views-view-unformatted--default.tpl.php, views-view-unformatted--default.tpl.php, views-view-unformatted--page.tpl.php, views-view-unformatted--frontpage--page.tpl.php

  • Row style output: views-view-fields.tpl.php, views-view-fields--frontpage.tpl.php, views-view-fields--default.tpl.php, views-view-fields--default.tpl.php, views-view-fields--page.tpl.php, views-view-fields--frontpage--page.tpl.php

How do I create a custom theme for printing the result using the fields method?

Edit1: i create new view mode with Chapabu answer.(create a custom build mode you can use Entity view modes)

now i see this result in front page : Image Link

now, this print default content with default html/css.in act, i need custom content default for my theme. Example : i dont need to print date and author content! i need to print image(Thumbs), Summary and content type. in html/css i need to list content in <ul><li></li></ul>Or Any Div or Span ... (custom html/CSS) How To Edit This HTML/CSS?

I Think Fields Method Better For My result. This Is TRUE? If YES, How To?

EDIT2: Example Of my Need Conetnt And CSS/HTML:

I need to design this block(in act example: article promoted front page Or last Article Or Last News ...) for show in vertical news ticker using jquery and css. this jquery plugin need to custom html/css:

 <h1>Latest News</h1>
<div class="newsTicker"> 
<ul>
<li><img class="Thumbs" src="" alt="">news item 1</li>
<li><img class="Thumbs" src="" alt="">news item 2</li>
<li><img class="Thumbs" src="" alt="">news item 3</li>
<li><img class="Thumbs" src="" alt="">news item 4</li>
<li><img class="Thumbs" src="" alt="">news item 5</li>
<li><img class="Thumbs" src="" alt="">news item 6</li>
<li><img class="Thumbs" src="" alt="">news item 7</li>
<li><img class="Thumbs" src="" alt="">news item 8</li>
</ul>
</div>

now, i need to custom content and html/css design views block for this.

share|improve this question
    
Hello, and welcome to Drupal Answers. What do you mean by, "create new custom view node theme"? –  kiamlaluno Nov 30 '12 at 12:15
1  
To create a custom build mode you can use Entity view modes –  Chapabu Nov 30 '12 at 12:23
    
@kiamlaluno:Hello, Thanks. I Edit My Question. my mean is: drupal have default view mode i.e: Teaser, RSS, search index, Tokens ... . now i need to add new(onother view mode theme) view mode for print result in node method. –  Eric Float Nov 30 '12 at 12:24
    
I'm really sorry, but I this question makes ZERO sense. There are bits and pieces that do, but I don't see and way of getting a sensible question from this. Perhaps you could edit it further and try to get your end requirements across more succinctly. –  Chapabu Nov 30 '12 at 17:33
    
@Chapabu: I thank you for your efforts to fix the problem and question. I add edit2 in my question. please see this. –  Eric Float Nov 30 '12 at 20:43

4 Answers 4

When you're not satisfied with the existing view modes you could create your own using either your own tiny plugin (see ready code) or use Display Suite. The new view mode will appear in Views UI for selecting.

I'd recommend however the true theming technique by using Views and fields. There you have more flexibility and control over the markup. You can do many things using Views UI (such as turning off the wrapper markup, linking a field to its content, overwriting some attributes, etc.) When you find out you cannot do something in Views UI this might be a reason for using a .tpl.php file at one of the output levels - in your case the style or row variants would be your friends)

It's recommendable that you watch some Views tutorials, such as NodeOne's Taming the Beast series or by Mustardseed Media (even if for Views 2 only) to get the idea how to tailor Views output to your needs.

Hope this helps.

share|improve this answer

You can use Entity view modes to create new view modes for your entities without writing any code.

The Drupal 7 successor to Build modes which will allow administrators to define custom view modes for entities. Custom entities are added to the entity registry via hook_entity_info_alter() so they are available to any code that uses entity_get_info() to provide a list of view modes for an entity. This includes node and user reference fields, Views, etc.

share|improve this answer
    
I'm really confused. i test your methods and edit my question. you see my problem? can you help me with any tuts or step by step docs? –  Eric Float Nov 30 '12 at 17:17

There are a few ways to theme a view in drupal. AS you said before you can output the view as 'node content' or as 'fields'. If you select 'node content', drupal will get the parameters for this content type as you config them in the content type menu (admin/structure/types/manage/{your-content-type}/display). If you select 'fields' you have to add every field you want to be displayed in the view and config it's output in the fields section of the view. There you can select if you want labels, the widget or the markup for the field.

With this you can configure the HTML output, I don't know if you mean css when you ask about theming.

The template files are for advanced output and just clicking in the views UI you'll get options to configure almost everything.

share|improve this answer

Armed with a custom content type that features a text area ‘featured_text’ and an image field ‘featured_image’ I went into views to create my slider. Here the fun started. Nivo slider requires a certain type of markup so I needed to theme each field and place a wrapper div around the view. Checking the views theming information link I was presented with 5 templates that (might) allow me to do this job. http://drupaltwig.net/blog/drupal-7-theming-views-field-templates

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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