Community Documentation

How to display thumbnails from the FlashVideo module in your AJAX Views bock

Last updated May 27, 2008. Created by ipwa on May 27, 2008.
Log in to edit this page.

<?php
function phptemplate_views_ajax_page_item($node) {
   
//return '<pre>' . print_r($node, true) . '</pre>';
   
$file=next($node->files);
   
$path = $node->nid;
   
$imgtag='<img src="/'.$file->filepath.'" alt="" />';
    return
l($imgtag, 'node/'. $node->nid, NULL, NULL, NULL, NULL, TRUE);
   
}
?>

You need to add this function to the template.php in your theme, or if it doesn't have one, create a file called template.php and put this function there. Remember not to include the php tags, which are there only to highlght the syntax.

After you add that theme function you need to create your AJAX View block.

  1. Create or edit a View
  2. Specify a Page view of any type
  3. Specify a Block view with "AJAX Paging Block View" type and the node count you want on each page, I recommend 4
  4. Specify an argument of type "AJAX Views: AJAX Selector" with "Display all values" specified
  5. If you have other arguments, make sure there are valid wildcards for them
  6. Add a Node:Published filter and leave it as default
  7. Add a Node:Type filter and set it to Is One Of -> video (the cck type where you upload your videos)
  8. Finally, either embed your view in a page via views_build_view('block', $view) or put your block in a region

By default your block will show the thumbnails in a vertical list, so we need to add some CSS to the theme:

/**********ajax views blocks**********/
.ajax_views_body ul {list-style: none; margin:0; padding: 10px 0;}
.ajax_views_body ul li {width: 150px; display: inline; padding-right: 20px;}

Hopefully this worked out for you, post any comments if you are having problems with this.

About this page

Drupal version
Drupal 5.x

Archive

Drupal’s online documentation is © 2000-2013 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License. Comments on documentation pages are used to improve content and then deleted.
nobody click here