I was wondering if there are any plans of making Random/Latest images block (like Image module has)?

Or should I simply try to implement it in Views?

Comments

mjohnq3’s picture

I've created a view with both Random and Latest Image blocks. Just Import it into Views to use it.

$view = new view;
$view->name = 'Gallery_views';
$view->description = 'Various views for Node Gallery';
$view->tag = '';
$view->view_php = '';
$view->base_table = 'node';
$view->is_cacheable = FALSE;
$view->api_version = 2;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->override_option('relationships', array(
  'fid' => array(
    'label' => 'Node Gallery: File',
    'required' => 0,
    'id' => 'fid',
    'table' => 'node_galleries',
    'field' => 'fid',
    'relationship' => 'none',
  ),
));
$handler->override_option('fields', array(
  'fid' => array(
    'label' => 'Click to visit this gallery',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'link_class' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'strip_tags' => 0,
      'html' => 0,
    ),
    'node_gallery_setting' => 'node_gallery_gallery',
    'view_mode' => 'teaser',
    'exclude' => 0,
    'id' => 'fid',
    'table' => 'node_galleries',
    'field' => 'fid',
    'relationship' => 'none',
    'override' => array(
      'button' => 'Override',
    ),
  ),
));
$handler->override_option('sorts', array(
  'random' => array(
    'id' => 'random',
    'table' => 'views',
    'field' => 'random',
  ),
));
$handler->override_option('access', array(
  'type' => 'none',
));
$handler->override_option('cache', array(
  'type' => 'none',
));
$handler->override_option('style_plugin', 'grid');
$handler->override_option('style_options', array(
  'grouping' => '',
  'columns' => '4',
  'alignment' => 'horizontal',
));
$handler = $view->new_display('block', 'Block Rnd', 'block_1');
$handler->override_option('sorts', array(
  'random' => array(
    'order' => 'ASC',
    'id' => 'random',
    'table' => 'views',
    'field' => 'random',
    'override' => array(
      'button' => 'Use default',
    ),
    'relationship' => 'none',
  ),
));
$handler->override_option('title', 'Random Image');
$handler->override_option('items_per_page', 1);
$handler->override_option('block_description', 'Random image');
$handler->override_option('block_caching', -1);
$handler = $view->new_display('block', 'Block Lat', 'block_2');
$handler->override_option('sorts', array(
  'created' => array(
    'order' => 'DESC',
    'granularity' => 'second',
    'id' => 'created',
    'table' => 'node',
    'field' => 'created',
    'override' => array(
      'button' => 'Use default',
    ),
    'relationship' => 'none',
  ),
));
$handler->override_option('title', 'Latest Image');
$handler->override_option('items_per_page', 1);
$handler->override_option('block_description', 'Latest image');
$handler->override_option('block_caching', -1);
dbeall’s picture

great!, just added this to the upcoming handbook. I will test it for alpha10 and .dev, I assume it should work. I see this issue is for alpha 9.. Never tried the old ones.
You don't happen to have a view handy for the thumbnail page? I am just plain dumb with arguments. well. at least i'm honest.
Edit: The handbook will be here in another day http://drupal.org/node/206776

mjohnq3’s picture

The view is based on alpha10; haven't tried any other versions. I haven't played around with any other views yet since I just started checking out Node Gallery yesterday!

kmonty’s picture

Version: 6.x-2.0-alpha9 » 6.x-2.x-dev
Category: feature » support
Status: Active » Fixed

It looks like this issue was solved. Thanks for the help guys!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

janis_lv’s picture

#1, thank you for the code.
What should be changed to get the image link directly to photo not the gallery?

dbeall’s picture

Status: Closed (fixed) » Active

there is a token in views that I think is for linking to image, but can't get it to work, yet.
It is in views fields, [fid] == Node Gallery Image: Image
I will try this again, after sleep and morning coffee..

dbeall’s picture

I still can't seem to get this to work, but not going to give up..
Anyone have any ideas or advise to link the thumbnail to the gallery image...

EDIT.10/18/2009. it's been a while, busy, busy.. will be back on node gallery possibly next week.
Edit #2, work is getting the best of me right now.. I will have a clean slate by Nov. 15th.

dbeall’s picture

Status: Active » Closed (fixed)

I think we can close this again,
we are working some more views and will post them in the handbook as they are tested..