Complex block (views Or Panels)

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

Hello

how Can I do complex block using views or panels like Attached image

AttachmentSize
Untitled-1.gif24.51 KB

Comments

You can create a view for

Gerard's picture

You can create a view for news stories, then create two displays. One would show the first article title and teaser text. Limit the number of nodes to 1.
In the second view you can limit the number of stories to 2, with an offset of 1. Here you choose to show only the field title, linked to node.
Just try this in views and make sure you install Advanced Help module.

If you save these views as Viewpanes you can insert them in your panel layout.

Ik hope this helps. I can recommend watching free video tutorials about views.

Single view option

Shyamala's picture

HI,

You can achieve this in Many way. Are the three articles sequential? Do all articles have images? How do you want to handle the case of no images.

Using fewer views would be my suggestion to make it more managable.

Using a single view - this will ensure that all the contents are unique and have a common sort order:

view type: Block, List
count: 3
fields:
Title
Image cache
teaser field
filter: to be defined
sort order:to be defined

In the view tpl - theme the block: identify the first element and theme it separately as against the listing of the rest.

Hope this helps.

Thank you Shyamalaand thank

drpl's picture

Thank you Shyamala
and thank Gerard

I did the steps exactly
But I did not understand the last line

In the view tpl - theme the block: identify the first element and theme it separately as against the listing of the rest.

I called
node title
node teaser ( cck field )
node Image (cck Imagefield)
for all but
How can I set the first item

In Row style output

print $row->nid;
print "<br />";
print $row->node_title;
print "<br />";
print $row->node_data_field_img_field_img_fid;
print "<br />";
print $row->node_data_field_img_field_img_list;
print "<br />";
print $row->node_data_field_img_field_img_data;
print "<br />";
print $row->node_data_field_art_short_field_art_short_value;
print "<br />";

Both approaches

yelvington's picture

Both approaches will work. Gerard's requires less PHP. It's the approach we use on our sites. In fact, I think the effect you describe could be accomplished without touching a .tpl.php at all, and relying just on CSS to theme the resulting compound mini-panel.

Packaging multiple displays into a single view helps keep your list of views from turning into an administrative nightmare.

In the setup we're using for our newspapers, we've created one view, based on reverse-chron, with multiple displays, and a similar multi-display view based on a nodequeue. These two views are real workhorses and get recycled throughout a site.

I prefer the nodequeue approach for important pages because it allows for precise control over editorial choices.

In addition to being able to pass offsets when you place a block on a Panels page, you also can pass nodequeue IDs or taxonomy terms, so you can use the same view setup in many situations.

Use Views theme wizard to

Shyamala's picture

Use Views theme wizard to generate the phptemplate_views_ function. Place this function in the template.php file. At the end of the node loop, foreach ($nodes as $i => $node), add the below code to redirect the first element and the rest to 2 different tpls.

if($i == 0) {
$items[] = _phptemplate_callback('views-list-__1', $vars);
}
else {
$items1[] = _phptemplate_callback('views-list-__2', $vars);
}

For support on Views theme Wizard check: http://drupal.org/node/220111

Can you do this another way?

RKopacz's picture

I realize that this thread is almost a year old, but I had a question.

Does anyone see anything implicitly wrong in generating a single display in views, with a list of, let's say three headlines, images (If desired), and teasers, and then use CSS to set the display on the image and teaser elements for the second and third nodes in the list to none? in other words:

.teaser-2, .teaser-3 {
display: none;
}

(obviously, would need to insert whatever unique classes Views spins out for those items).

I think this would work, but are there any drawbacks to this approach?

Also . . .

RKopacz's picture

Can you point me to any tutorials on how to do Gerard's solution? Not quite getting it. Does the viewpanes option become available when you have installed panels?

Newspapers on Drupal

Group organizers

Group categories

Topics - Newspaper on Drupal

Group notifications

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

Hot content this week